> ## 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.

# Parse Commands

> Data parsing commands for extracting and parsing data from various formats

Parse commands enable you to extract and parse data from various formats including JSON, HTML, XML, and other structured data formats. These commands are essential for transforming raw data into usable structured formats.

## Overview

Parse commands provide functionality for:

* Extracting data using JSONPath queries
* Parsing JSON structures
* Transforming data formats
* Extracting specific fields from complex data structures
* Mapping data between different structures

## Available Commands

<CardGroup cols={2}>
  <Card title="JSON Parse" icon="code" href="/stream/commands/parse/json-parse">
    Parse JSON data into structured objects
  </Card>

  <Card title="Json Path" icon="code" href="/stream/commands/parse/json-path">
    Extract data using JSONPath expressions
  </Card>
</CardGroup>

## Common Use Cases

* **API Response Parsing**: Extract specific fields from API responses
* **Data Transformation**: Transform data structures for downstream processing
* **Field Extraction**: Extract specific values from nested JSON structures
* **Data Mapping**: Map data between different formats
* **Response Processing**: Process and structure HTTP response data

## JSONPath Syntax

JSONPath commands use JSONPath expressions to query JSON data. Common patterns include:

| Pattern               | Description                | Example              |
| --------------------- | -------------------------- | -------------------- |
| `$`                   | Root element               | `$`                  |
| `$.field`             | Access field at root       | `$.data`             |
| `$[*]`                | All array elements         | `$.items[*]`         |
| `$[0]`                | First array element        | `$.items[0]`         |
| `$[-1]`               | Last array element         | `$.items[-1]`        |
| `$.field[*].subfield` | Nested array access        | `$.data.items[*].id` |
| `$..field`            | Recursive search for field | `$..name`            |

### Common JSONPath Patterns

**Extract all IDs:**

```json theme={null}
$.items[*].id
```

**Get first item:**

```json theme={null}
$[0]
```

**Nested access:**

```json theme={null}
$.data.events[*].id
```

**Recursive search:**

```json theme={null}
$..name
```

## Command Parameters

Parse commands typically support the following parameters:

| Parameter    | Type   | Description                        | Required            |
| ------------ | ------ | ---------------------------------- | ------------------- |
| **source**   | string | Source data to parse               | Yes                 |
| **jsonPath** | string | JSONPath expression for extraction | Yes (for Json Path) |
| **key**      | string | Key name for extracted data        | Yes                 |
| **input**    | string | Input data reference               | Yes                 |

## Variable Support

Parse commands support variable interpolation in source data and JSONPath expressions:

```json theme={null}
{
  "command": "json-path",
  "params": {
    "jsonPath": "$.data.items[*].title",
    "input": "@{PREVIOUS_OUTPUT}",
    "key": "extracted_titles"
  }
}
```

## Best Practices

* **Test JSONPath Queries**: Use the Test panel to validate JSONPath syntax
* **Verify Source Data Structure**: Check actual data structure before writing queries
* **Use Descriptive Keys**: Use clear, descriptive key names for extracted data
* **Handle Missing Data**: Account for missing fields or null values
* **Start Simple**: Begin with simple queries and build complexity gradually

## Troubleshooting

### JSONPath Queries Not Working

If JSONPath queries return no results:

1. **Verify Source Data**: Check the actual structure of source data using the Test panel
2. **Test Syntax**: Validate JSONPath syntax matches the data structure
3. **Check Source Selection**: Ensure the correct source is selected
4. **Review Query Examples**: Start with simpler queries and build complexity

### Common Issues

* **Incorrect JSONPath Syntax**: Verify syntax matches JSONPath specification
* **Data Structure Mismatch**: Ensure query matches actual data structure
* **Missing Fields**: Handle cases where expected fields may not exist
* **Null Values**: Account for null or undefined values in data

## Related Commands

* [HTTP Commands](/stream/commands/http) - Fetch data to parse
* [Object Mapper](/stream/commands/parse/object-mapper) - Transform parsed data
* [Validation Commands](/stream/commands/validation) - Validate parsed data
