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: 1007Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| source | string | JSON string to parse | Yes |
| key | string | Key name for storing parsed result | Yes |
| input | string | Input data reference (e.g., @{PREVIOUS_OUTPUT}) | Yes |
| validate | boolean | Whether to validate JSON syntax | No (defaults to true) |
Usage Examples
Basic JSON Parsing
Parsing HTTP Response
Parsing with Validation
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
Using Parsed Data
Parsed data can be used by subsequent commands: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
validateis 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
Related Commands
- Json Path - Extract data from parsed JSON
- HTTP Request - Fetch JSON data to parse
- Object Mapper - Transform parsed data structures
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