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

# JSONata

> Evaluate JSONata expressions against input data

The JSONata command (Command Type: 1022) evaluates a [JSONata expression](https://jsonata.org/) against the current input data. JSONata is a lightweight query and transformation language for JSON.

## Overview

The JSONata command provides functionality for:

* Evaluating complex transformation expressions against JSON data
* Outputting results to the `data` field or `children` array
* Setting an evaluation timeout to prevent runaway expressions

## Command Type

**Command Type ID:** 1022

## Parameters

| Parameter      | Type   | Description                                                                                                                                                                             | Required |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| **expression** | string | Inline JSONata expression string                                                                                                                                                        | Yes      |
| **timeout**    | number | Timeout for evaluation in milliseconds                                                                                                                                                  | Yes      |
| **key**        | string | Where to store the evaluation result. `"data"` (default) stores in data field; `"children"` stores in children array (result must be an array). Possible values: `"data"`, `"children"` | No       |

## Usage Examples

### Sum a Field Across an Array

```json theme={null}
{
  "command": "jsonata",
  "params": {
    "expression": "$sum(items.price)",
    "timeout": 5000
  }
}
```

### Transform and Restructure Data

```json theme={null}
{
  "command": "jsonata",
  "params": {
    "expression": "items.{ 'id': id, 'label': name & ' (' & status & ')' }",
    "timeout": 5000,
    "key": "children"
  }
}
```

### Filter with Expression

```json theme={null}
{
  "command": "jsonata",
  "params": {
    "expression": "items[status = 'active']",
    "timeout": 3000,
    "key": "children"
  }
}
```

### String Concatenation

```json theme={null}
{
  "command": "jsonata",
  "params": {
    "expression": "firstName & ' ' & lastName",
    "timeout": 2000
  }
}
```

## Output Key Options

| Value        | Behaviour                                                                      |
| ------------ | ------------------------------------------------------------------------------ |
| `"data"`     | Stores the expression result in the `data` field (default)                     |
| `"children"` | Stores the expression result in the `children` array — result must be an array |

## Common Use Cases

* **Aggregations**: Sum, average, or count values across arrays
* **Complex Transformations**: Reshape data structures in a single expressive step
* **Conditional Logic**: Apply conditional transformations without multiple commands
* **String Formatting**: Concatenate or format string fields

## Related Commands

* [Transform By JDM](/stream/commands/parse/transform) - Transform data using JDM mapping rules
* [Zen Parse Expression](/stream/commands/parse/zen-parse) - Evaluate Zen expressions
* [Json Path](/stream/commands/parse/json-path) - Extract data using JSONPath
