---
title: JSON Transformation
description: Learn about JSON Transformation
documentId: ipaas-legacy-json-transformation
locale: en-US
---

**JSON Transformation** is a *step* that facilitates the manipulation and transformation of JSON data between different systems and applications. 
It is an essential resource for ensuring data consistency and compatibility between various APIs and data sources.

---
To transform the JSON, you will use the JSONata language. 
For support, the [JSONata Exerciser](https://try.jsonata.org/) can be accessed directly from the *step* form. 
In it, you can:

* Define the structure of the input data.
* Create transformation expressions that generate the output data in the desired format.
* Check for errors in the expression.

<Callout type="note" title="NOTE">
To understand this language in detail, consult the [official JSONata documentation](https://docs.jsonata.org/overview.html).
</Callout>
---

Below, learn how to add JSON Transformation to the canvas and configure its form.

## Add JSON Transformation to the canvas

<Steps>
<Step>
Click the ![tool icon with plus sign](https://creative-ball-51b3fc85c0.media.strapiapp.com/general_Tools_Icon_43cb976f10.png) icon in the left editing menu.
</Step>
<Step>
Select **JSON Transformation** to add it to the canvas.
You can use the search bar ![](https://creative-ball-51b3fc85c0.media.strapiapp.com/search_steps_icon_245a7221ea.png) to find it.

<Callout type="note" title="NOTE">
You can add it more than once.
In this case, each time the tool is added, a number is appended to the name (JSON Transformation 1, JSON Transformation 2, JSON Transformation 3).
</Callout>
</Step>
<Step>
Connect **JSON Transformation** to the flow *steps*.
This tool can connect with one previous *step* and one subsequent *step*.
</Step>
</Steps>

<Callout type="tip" title="TIP">
To copy the *step*, click the ![copy icon](https://creative-ball-51b3fc85c0.media.strapiapp.com/copy_step_icon_fd3cbe733c.png) button.
If the *step* form is already configured, the settings will be copied as well.
</Callout>

To delete **JSON Transformation** from the canvas, select it and click the ![trash icon](https://creative-ball-51b3fc85c0.media.strapiapp.com/remove_Icon_486c52eeeb.png) button. 

## Configure the form

<Steps>
<Step>
Select **JSON Transformation** on the canvas.
</Step>
<Step>
Click the edit icon ![pencil icon](https://creative-ball-51b3fc85c0.media.strapiapp.com/edit_icon_34464736ca.png).
</Step>
<Step>
Fill in the following form fields:
* **Name**: enter a unique name for the *step*. 
By default, you will see "JSON Transformation".
* **Input Data**: select the *step* and its source *payload* to apply the data transformation.
You will see the request and response data from connectors and the request data from the trigger.
</Step>
<Step>
Click the **GO TO JSONATA** button ![](https://creative-ball-51b3fc85c0.media.strapiapp.com/open_in_new_Icon_4201b7f235.png). 
You will be redirected to the [JSONata Exerciser](https://try.jsonata.org/).
</Step>
<Step>
Request the data model from the application provider for your input mapping.
</Step>
<Step>
Insert the data model on the left side of the screen.
</Step>
<Step>
Build your expression in the upper right corner of the screen using the JSONata language.
</Step>
<Step>
Use version 2.0.x. 
You can find it in the upper right corner of the screen.

<Callout type="note" title="NOTE">
See an example of how to create an expression in a [flow that integrates E-commerce and CRM](#integrating-e-commerce-and-crm).

If you have questions, you can consult the [JSONata documentation](https://docs.jsonata.org/overview.html).
</Callout>
</Step>
<Step>
Copy the completed expression.
</Step>
<Step>
Return to the **JSON Transformation** screen in **Sensedia Integrations**.
* In the **JSONata** field, paste the expression obtained in step 7 and copied in step 9 to map the data for the transformation process.

<Callout type="tip" title="TIP">
If the expression has any errors, you will see a red message in the lower right corner of this field.
</Callout>
</Step>
<Step>
Click **SAVE**.
</Step>
</Steps>

![Building an expression in JSONata Exerciser](https://creative-ball-51b3fc85c0.media.strapiapp.com/jsonata_pt_cea5ff1726.gif)

<Callout type="note" title="NOTE">
To use the response in connectors, access the [Data Mapping with Full Body](/docs/integrations/ipaas-legacy-connectors-rest-api#data-mapping-with-full-body) documentation.
</Callout>

## Example

See an example of how to use **JSONata Exerciser** to transform a JSON:

### Integrating E-commerce and CRM

Let's consider a flow that integrates an E-commerce platform with a CRM system.

In this scenario, when a new order is placed on the E-commerce platform, the order details need to be transformed from the E-commerce platform's JSON format to a format compatible with the CRM system.

Thus, we have the initial data from the E-commerce platform:

**Input data (E-commerce)**

```json
{
  "orderId": "123456",
  "customerName": "John Doe",
  "email": "john@example.com",
  "totalAmount": 100.50,
  "items": [
    {
      "productId": "ABC123",
      "productName": "Widget",
      "quantity": 2,
      "price": 25.25
    },
    {
      "productId": "DEF456",
      "productName": "Gadget",
      "quantity": 1,
      "price": 50.00
    }
  ]
}
```

And the data in the desired format for inclusion in the CRM:

**Output data (CRM)**

```json
{
  "order_id": "123456",
  "customer": {
    "name": "John Doe",
    "email": "john@example.com"
  },
  "products": {
    "id": [
      "ABC123",
      "DEF456"
    ],
    "name": [
      "Widget",
      "Gadget"
    ],
    "quantity": [
      2,
      1
    ],
    "price": [
      25.25,
      50
    ]
  },
  "total_amount": 100.5
}
```

<Callout type="note" title="NOTE">
The data is the same, but the nomenclature and the way of organizing the information are different for the two systems.
</Callout>

To achieve the desired result, we will map the source JSON format to the destination JSON format. 

This mapping can involve renaming fields, restructuring data, and performing calculations. 

For example:

* Map `"orderId"` to `"order_id"`.
* Map `"customerName"` to `"customer.name"`.
* Map `"email"` to `"customer.email"`.
* Map each item in the `"items"` array to the corresponding structure in the `"products"` array. 
* Sum the price of all items to calculate the total.

In this specific case, the expression we will use to obtain the mapping above will be:

**JSON transformation expression**

```json
{
  "order_id": orderId,
  "customer": {
    "name": customerName,
    "email": email
  },
  "products": items {
    "id": productId,
    "name": productName,
    "quantity": quantity,
    "price": price
  },
  "total_amount": totalAmount
}
```

After applying the JSON transformation expression, the resulting JSON data will be compatible with the CRM system and can be sent as a request to create a new order record.
