> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bringits.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON Parse

> Parse JSON data into structured objects

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

| 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

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

### Parsing HTTP Response

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

### Parsing with Validation

```json theme={null}
{
  "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

```json theme={null}
{
  "parsed_data": {
    "field1": "value1",
    "field2": "value2",
    "nested": {
      "field": "value"
    }
  }
}
```

### Using Parsed Data

Parsed data can be used by subsequent commands:

```json theme={null}
{
  "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

## Related Commands

* [Json Path](/stream/commands/parse/json-path) - Extract data from parsed JSON
* [HTTP Request](/stream/commands/http/http-request) - Fetch JSON data to parse
* [Object Mapper](/stream/commands/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
