1. Home
  2. Integrations
  3. JSON Transformation

JSON Transformation

Learn about JSON Transformation

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

To understand this language in detail, consult the official JSONata documentation.


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

Add JSON Transformation to the canvas

Click the tool icon with plus sign icon in the left editing menu.

Select JSON Transformation to add it to the canvas. You can use the search bar to find it.

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

Connect JSON Transformation to the flow steps. This tool can connect with one previous step and one subsequent step.

TIP

To copy the step, click the copy icon button. If the step form is already configured, the settings will be copied as well.

To delete JSON Transformation from the canvas, select it and click the trash icon button.

Configure the form

Select JSON Transformation on the canvas.

Click the edit icon pencil icon.

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.

Click the GO TO JSONATA button . You will be redirected to the JSONata Exerciser.

Request the data model from the application provider for your input mapping.

Insert the data model on the left side of the screen.

Build your expression in the upper right corner of the screen using the JSONata language.

Use version 2.0.x. You can find it in the upper right corner of the screen.

NOTE

See an example of how to create an expression in a flow that integrates E-commerce and CRM.

If you have questions, you can consult the JSONata documentation.

Copy the completed expression.

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

If the expression has any errors, you will see a red message in the lower right corner of this field.

Click SAVE.

Building an expression in JSONata Exerciser

NOTE

To use the response in connectors, access the Data Mapping with Full Body documentation.

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)

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

Output data (CRM)

NOTE

The data is the same, but the nomenclature and the way of organizing the information are different for the two systems.

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

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.

How happy are you with this page?

We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more