Skip to main content
The JSON Parse command (Command Type: 1007) enables you to parse JSON data into structured objects. This command is essential for processing JSON responses from APIs and transforming raw JSON strings into usable data structures.

Overview

The JSON Parse command provides functionality for:
  • Parsing JSON strings into JavaScript objects
  • Validating JSON syntax
  • Handling malformed JSON gracefully
  • Transforming JSON data structures
  • Preparing data for subsequent processing

Command Type

Command Type ID: 1007

Parameters

ParameterTypeDescriptionRequired
sourcestringJSON string to parseYes
keystringKey name for storing parsed resultYes
inputstringInput data reference (e.g., @{PREVIOUS_OUTPUT})Yes
validatebooleanWhether to validate JSON syntaxNo (defaults to true)

Usage Examples

Basic JSON Parsing

{
  "command": "json-parse",
  "params": {
    "source": "@{PREVIOUS_OUTPUT}",
    "key": "parsed_data",
    "input": "@{PREVIOUS_OUTPUT}"
  }
}

Parsing HTTP Response

{
  "command": "json-parse",
  "params": {
    "source": "${http_response.body}",
    "key": "api_response",
    "input": "@{PREVIOUS_OUTPUT}"
  }
}

Parsing with Validation

{
  "command": "json-parse",
  "params": {
    "source": "@{PREVIOUS_OUTPUT}",
    "key": "parsed_data",
    "input": "@{PREVIOUS_OUTPUT}",
    "validate": true
  }
}

Variable Support

The JSON Parse command supports variable interpolation in:
  • Source: Use @{VARIABLE} to reference previous command output
  • Input: Reference data from previous commands

Common Variable Patterns

  • Previous Output: @{PREVIOUS_OUTPUT} - Output from previous command
  • HTTP Response: ${http_response.body} - Body from HTTP request
  • Step Output: @{STEP_OUTPUT} - Output from previous step

Output Structure

The JSON Parse command stores parsed data under the specified key:

Output Format

{
  "parsed_data": {
    "field1": "value1",
    "field2": "value2",
    "nested": {
      "field": "value"
    }
  }
}

Using Parsed Data

Parsed data can be used by subsequent commands:
{
  "command": "json-path",
  "params": {
    "jsonPath": "$.parsed_data.items[*].id",
    "input": "@{PREVIOUS_OUTPUT}"
  }
}

Error Handling

The JSON Parse command handles various error scenarios:
  • Invalid JSON: Returns error for malformed JSON strings
  • Missing Source: Handles missing or undefined source data
  • Validation Errors: Reports validation errors when validate is true

Best Practices

  • Validate JSON: Always enable validation for production workflows
  • Handle Errors: Implement error handling for parsing failures
  • Use Descriptive Keys: Use clear, descriptive key names for parsed data
  • Check Source Format: Verify source data is valid JSON before parsing
  • Chain with Json Path: Use JSON Parse followed by Json Path for extraction

Common Use Cases

  • API Response Processing: Parse JSON responses from HTTP requests
  • Data Transformation: Transform JSON data structures
  • Data Preparation: Prepare JSON data for extraction
  • Response Parsing: Parse HTTP response bodies

Troubleshooting

Invalid JSON Error

If parsing fails with invalid JSON:
  • Verify source data is valid JSON
  • Check for trailing commas or syntax errors
  • Validate JSON structure matches expected format

Missing Data

If parsed data is missing:
  • Verify source data contains expected fields
  • Check key name matches usage in subsequent commands
  • Ensure input reference is correct