![jsonata icon](/docs/img/components/icons/60/anNvbmF0YQ==.png)

# JSONata Connector

key: jsonata[Connector Changelog](#changelog)

## Description[​](#description "Direct link to Description")

[JSONata](https://jsonata.org/) is a query and transformation language for JSON data. This component allows you to transform data using the JSONata query and transformation language. JSONata is helpful when you have a predictable data structure as an input, and you want to output a modified data structure. JSONata includes common functions you might execute on a data set - things like `map`, `filter`, `sort`, `sum`, `string.split` (the list goes on).

For example, suppose you had data that read:

```json
{
  "example": [{ "value": 4 }, { "value": 7 }, { "value": 13 }]
}

```

If you applied a JSONata expression that read `$sum(example.value)` to this data, `24` would be returned because `example.value` generates an array of `[4,7,13]`, and `$sum` finds the sum of those values.

You can find documentation and examples of JSONata expressions and functions on [JSONata's documentation](https://docs.jsonata.org/).

When to use the Code component instead

The JSONata component is helpful for data transformations, but if you are already comfortable with JavaScript or would like more flexibility in your data transformation, check out the [code component](https://prismatic.io/docs/components/code.md) instead.

## Testing JSONata Expressions[​](#testing-jsonata-expressions "Direct link to Testing JSONata Expressions")

JSONata provides an incredibly useful [JSONata test environment](https://try.jsonata.org/) where you can try out expressions against data sets. This tool gives you a tight feedback loop, so you can test expressions quickly before pasting them into a JSONata step of an integration.

## Some JSONata Examples[​](#some-jsonata-examples "Direct link to Some JSONata Examples")

Here are a couple examples that show off how to use JSONata expressions to process data:

### Concatenating and Filtering Data[​](#concatenating-and-filtering-data "Direct link to Concatenating and Filtering Data")

In this example, a large block of information about a user is input. The JSONata expression concatenates the user's first and last name, and uses [JSONata predicates](https://docs.jsonata.org/predicate#examples) to filter for the user's mobile phone number:

* Input Data
* JSONata Expression
* Result

```json
{
  "FirstName": "Fred",
  "Surname": "Smith",
  "Age": 28,
  "Address": {
    "Street": "Hursley Park",
    "City": "Winchester",
    "Postcode": "SO21 2JN"
  },
  "Phone": [
    {
      "type": "home",
      "number": "0203 544 1234"
    },
    {
      "type": "office",
      "number": "01962 001234"
    },
    {
      "type": "office",
      "number": "01962 001235"
    },
    {
      "type": "mobile",
      "number": "077 7700 1234"
    }
  ],
  "Email": [
    {
      "type": "office",
      "address": ["fred.smith@my-work.com", "fsmith@my-work.com"]
    },
    {
      "type": "home",
      "address": ["freddy@my-social.com", "frederic.smith@very-serious.com"]
    }
  ],
  "Other": {
    "Over 18 ?": true,
    "Misc": null,
    "Alternative.Address": {
      "Street": "Brick Lane",
      "City": "London",
      "Postcode": "E1 6RF"
    }
  }
}

```

```text
{
  "name": FirstName & " " & Surname,
  "mobile": Phone[type = "mobile"].number
}

```

```json
{
  "name": "Fred Smith",
  "mobile": "077 7700 1234"
}

```

### Using Built-in JSONata Functions[​](#using-built-in-jsonata-functions "Direct link to Using Built-in JSONata Functions")

In this example, information about a point-of-sale account lists an account name and an array of orders for several products. The expression uses the built-in `$sum` and `$map` functions to generate an object containing account name and an array of orders with the total owed for each order.

* Input Data
* JSONata Expression
* Result

```json
{
  "Account": {
    "Account Name": "Firefly",
    "Order": [
      {
        "OrderID": "order103",
        "Product": [
          {
            "Product Name": "Bowler Hat",
            "ProductID": 858383,
            "SKU": "0406654608",
            "Description": {
              "Colour": "Purple",
              "Width": 300,
              "Height": 200,
              "Depth": 210,
              "Weight": 0.75
            },
            "Price": 34.45,
            "Quantity": 2
          },
          {
            "Product Name": "Trilby hat",
            "ProductID": 858236,
            "SKU": "0406634348",
            "Description": {
              "Colour": "Orange",
              "Width": 300,
              "Height": 200,
              "Depth": 210,
              "Weight": 0.6
            },
            "Price": 21.67,
            "Quantity": 1
          }
        ]
      },
      {
        "OrderID": "order104",
        "Product": [
          {
            "Product Name": "Bowler Hat",
            "ProductID": 858383,
            "SKU": "040657863",
            "Description": {
              "Colour": "Purple",
              "Width": 300,
              "Height": 200,
              "Depth": 210,
              "Weight": 0.75
            },
            "Price": 34.45,
            "Quantity": 4
          },
          {
            "ProductID": 345664,
            "SKU": "0406654603",
            "Product Name": "Cloak",
            "Description": {
              "Colour": "Black",
              "Width": 30,
              "Height": 20,
              "Depth": 210,
              "Weight": 2
            },
            "Price": 107.99,
            "Quantity": 1
          }
        ]
      }
    ]
  }
}

```

```text
{
  "Account": Account.`Account Name`,
  "Orders": [
    $map(Account.Order, function($v){
      {
        "id": $v.OrderID,
        "total": $sum($map($v.Product, function($p) {
          $p.Price * $p.Quantity
        }))
      }
    })
  ]
}

```

```json
{
  "Account": "Firefly",
  "Orders": [
    {
      "id": "order103",
      "total": 90.57
    },
    {
      "id": "order104",
      "total": 245.79
    }
  ]
}

```

## Actions[​](#actions "Direct link to Actions")

### Transform[​](#transform "Direct link to Transform")

Transform data using JSONata | **key: transform**

| Input      | Notes                                                                  | Example     |
| ---------- | ---------------------------------------------------------------------- | ----------- |
| Data       | This is an object with properties to feed into the JSONata expression. | See Example |
| Expression | A JSONata expression used to generate a string.                        | See Example |

Example Payload for <!-- -->Transform[⤓](https://prismatic.io/docs/example-payloads/jsonata/actions/transform.json "Download example payload")

Loading…

***

## Changelog[​](#changelog "Direct link to Changelog")

### 2026-03-31[​](#2026-03-31 "Direct link to 2026-03-31")

Various modernizations and documentation updates
