Skip to content

JSONata#

This task evaluates a JSONata expression against a given JSON object.

Workflows#

Data Flow Control Flow

Inputs#

Name Data Type Description
value Object The JSON object
expression String The JSONata expression
Activate Any Activates the task execution

Outputs#

Name Data Type Description
result Object The result of evaluating the JSONata expression against the JSON object
Success Boolean Returns true if the task completes successfully
Error Error Error that occurred during the processing of this task

Settings#

On the General Tab, you have the usual settings and the following options settings:

Name Data Type Description
Expression String The JSONata expression

Behavior#

The task evaluates a JSONata expression against a given JSON object to dynamically extract, transform, or query specific data from the JSON object. The output of the task can be a filtered subset of the JSON data, a transformed version of it, or specific values extracted based on the expression's logic.

The expression can come from the Expression setting on the General tab or from the expression input. When the expression input receives a value, it replaces the configured setting. The value input accepts a JSON object or a string that can be parsed as a JSON object; any other value emits an Error. The task also emits an Error when no expression is defined or when the expression is not valid JSONata.

Note

Full reference for the JSONata expression language is available at https://docs.jsonata.org/. Use https://try.jsonata.org/ ⧉ as a playground to test expressions.

Examples#

Extract a value with the Expression setting#

Set the Expression setting on the General tab to:

User.Name

When the value input receives the following object:

{ "User": { "Name": "Hello World" } }

The result output emits "Hello World" and Success emits true. The same result is emitted when the value input receives the object as a JSON formatted string.

Transform arrays with the expression input#

Send the expression through the expression input instead of the setting:

Parameters.[NumericValues]

When the value input receives the following object:

{
  "Resource": { "Name": "Oven" },
  "Parameters": [
    { "Class": "Pressure", "Name": "Oven", "NumericValues": [1.1, 2.2], "UnitOfMeasure": "bar" },
    { "Class": "Temperature", "Name": "Oven", "NumericValues": [3.3, 4.4], "UnitOfMeasure": "C" }
  ]
}

The expression selects the NumericValues array of each entry in Parameters, so the result output emits:

[[1.1, 2.2], [3.3, 4.4]]