JSON Transformer

Discover more about the JSON Transformer component and how to use it on the Digibee Integration Platform.

JSON Transformer allows transformations in the JSON being processed in your pipeline. With a configuration form you can perform a variety of actions.

Parameters

Take a look at the configuration options for the component. Parameters supported by Double Braces expressions are marked with (DB).

Parameter
Description
Default value
Data type

Actions

Add or remove different actions.

N/A

Options of Actions

Description

This field is used to document the action.

N/A

String

Type

Set the action that will be executed, such as: Rename Property, Edit Property, Remove Property, and Remove Property with Condition. See more details about each action in the section below.

Rename Property

String

Action Settings

Additional settings related to the selected action.

N/A

Options of Action Settings

Root Path

Must be activated when the JSON property is in the root of the object. When this option is activated, Path (Dot Notation) is not available.

False

Boolean

Path (Dot notation)

Must be filled when the JSON property isn't in the root of the object. It allows indicating dot notation, which makes it simple to access different JSON levels, including going through the JSON array and object.

N/A

String

Properties to be renamed (DB)

This parameter is shown only when action Rename Property is selected. Must be filled with the key and value you want to rename.

N/A

Key-value Pairs

Values to be edited (DB)

This parameter is shown only when action Edit Property is selected. Must be filled with the key and value you want to edit.

N/A

Key-value Pairs

Properties to be removed (DB)

This parameter is shown only when actions Remove Property or Remove Property with Condition are selected. Must be filled with the exact key name of the JSON (in case of Remove Property) or key and value you want to remove (in case of Remove Property with Condition).

N/A

String / Key-value Pairs

Fail On Error

If the option is activated, the execution of the pipeline with error will be interrupted; otherwise, the pipeline execution proceeds, but the result will show a false value for the “success” property.

False

Boolean

When using Double Braces, the values of the properties to be changed must be accessed with the use of the word "item". With the word "item" it's possible to obtain values of all properties in the same JSON level that's being accessed.

Examples:

{{ item.keyName }}
{{ CONCAT(item.customer.id, item.customer.name) }}
{{ FORMATDATE( item.orders.dateAdded, "dd-MM-yyyy", "dd MMM yyyy") }}

Parameters additional information

Type

  • Rename Property: Renames the JSON key to a new key, which can consist of a static or dynamic value composed by Double Braces.

  • Edit Property: Allows the transformation of the values in a property through Double Braces.

  • Remove Property: Removes properties in any structure of JSON.

  • Remove Property with Condition: With the logical operators of the functions, you can define a condition so that "true" is returned if the property must be removed.

Messages flow

Input

This component doesn't expect any specific input message, only if an expression in Double Braces is informed in some of its fields.

Output

Because it's a component that transforms the input JSON, the output is the result of the configurations defined by you.

If no property defined in the component configurations is found in JSON, the result will be the same one of the input JSON.

To better understand the messages flow in the Platform, refer to Messages processing.

JSON Transformer in action

See below how the component behaves in certain situations and what its respective configurations are.

Renaming properties

The properties can be renamed through static or dynamic values composed by Double Braces. These properties can be in an object, array or in the root.

In this example, see how to rename "a" to "id" and "b" to "name". The component configurations must be:

Input

{
  "products": [
          {
           "a": 1,
           "b": "Table"
          },
          {
           "a": 2,
           "b": "Chair"
          }
  ]
}

Configurations

Output

{
  "products": [
          {
           "id": 1,
           "name": "Table"
          },
          {
           "id": 2,
           "name": "Chair"
          }
  ]
}

Editing properties

The values can be transformed by applying Double Braces and functions from the Digibee Integration Platform. This property can be in an object, array or in the root.

It's possible to apply functions such as FORMATDATE, CONCAT, REPLACE, FORMATNUMBER, among others.

To better understand how these resources work, read the article Double Braces Functions.

In this example, see how to transform the "id" from number to string. The component configurations must be:

Input

{
  "products": [
          {
           "id": 1,
           "name": "Table"
          },
          {
           "id": 2,
           "name": "Chair"
          }
  ]
}

Configurations

Output

{
  "products": [
          {
           "id": "1",
           "name": "Table"
          },
          {
           "id": "2",
           "name": "Chair"
          }
  ]
}

Removing properties with decision conditions

The properties can be removed by using the logical operators of the Double Braces functions. It's possible to define a condition that, when resolved to "true", will indicate that the property must be removed. These properties can be in an object, array or in the root.

In this example, see how to remove "description" with a null value. The component configurations must be:

Input

{
  "products": [
          {
           "id": 1,
           "name": "Table",
           "description": "Tea Table",   
},
          {
           "id": 2,
           "name": "Chair",
           "description": null
          }
  ]
}

Configurations

Output

{
  "products": [
          {
           "id": 1,
           "name": "Table",
           "description": "Tea Table",     
},
          {
           "id": 2,
           "name": "Chair"
          }
  ]
}

Removing properties only by the name

The properties can be removed just by declaring their names in the Properties to be removed field. These properties can be in an object, array or in the root.

Some of the parameters above accept Double Braces. To better understand how this language works, read the article How to reference data using Double Braces.

Last updated