Skip to main content

Overview

The JSON tool provides operations for parsing, querying, validating, and transforming JSON data with JSONPath-like query support.

json

Parse, query, and transform JSON data. Supports JSONPath-like queries for extracting values from complex structures. Input Parameters
string
required
The JSON operation to perform. Must be one of: parse, query, stringify, validate
required
JSON input data. Pass a string for parse, or any JSON value (object, array, string, number, boolean, null) otherwise.
string
JSONPath-like path for query operation (e.g., foo.bar[0].baz)

Operations

parse

Parse a JSON string into a structured value. Input
string
required
JSON string to parse
Output Returns the parsed JSON value (object, array, string, number, boolean, or null). Example
Response
Error Conditions
  • InvalidParameters: data is not a string or contains invalid JSON

stringify

Convert a JSON value to a pretty-printed string. Input
string
required
JSON string representing the value to stringify
Output Returns a JSON string (pretty-printed with indentation). Example
Response

query

Extract a value from JSON using a JSONPath-like path. Input
string
required
JSON string to query
string
required
Path to the value (e.g., user.name, items[0].id, config.api.endpoints[2].url)
Output Returns the value at the specified path. Example
Response
Path Syntax
  • Dot notation for object fields: foo.bar.baz
  • Array indexing with brackets: items[0], list[5]
  • Combined: user.orders[2].items[0].name
Error Conditions
  • InvalidParameters: Missing path parameter or invalid array index
  • ExecutionFailed: Field not found or array index out of bounds

validate

Check if a string contains valid JSON. Input
string
required
String to validate as JSON
Output
boolean
True if string is valid JSON, false otherwise
Example
Response
Invalid JSON Example
Response

Examples

Extract Nested Value

Response: "localhost"

Access Array Element

Response: "Bob"

Parse API Response

Response:

Format JSON

Response:

Use Cases

Extract Configuration Values

Parse config files and extract specific settings:

Validate External Data

Check if external input is valid JSON before processing:
Extract values from nested API responses:

Pretty Print JSON

Format compact JSON for readability:

Error Handling

  • Unknown operation
  • data is not a string when required
  • Invalid JSON in data string
  • Missing path for query operation
  • Invalid array index in path
  • Field not found at specified path
  • Array index out of bounds
  • Failed to stringify JSON

Technical Details

Sanitization

No sanitization required - internal tool with no external data access.

Approval

No approval required - safe internal operation.

Path Resolution

Paths are resolved left-to-right:
  1. Split on . to get segments
  2. For each segment, check for array indexing [n]
  3. Navigate to field, then to array index if present
  4. Return final value

OpenAI Compatibility

The data parameter is intentionally freeform (no type constraint) for OpenAI compatibility. OpenAI rejects union types containing array unless items is also specified.