Modifier

Modifiers can modify and transform data on the fly. They allow you to apply a JSONata or JavaScript expression to change the structure and value of an output before passing it to the next step in your flow.

A Modifier can use either JSONata or a JavaScript expression to perform transformations. By default, it is set to JSONata. You can switch between types at any time by right-clicking the modifier and selecting Jsonata or Expression.

circle-exclamation

JSONata

JSONata is a lightweight query and transformation language designed for JSON data.

  • To refer to the value from the preceding output, use the $ sign.

  • For JSONata functions, however, the previous value is automatically considered as an argument, eliminating the need to explicitly fill it into the brackets.

  • For a complete guide, refer to the official JSONata documentationarrow-up-right.

Examples

1. Wrap a value in an object: This expression takes the incoming value ($) and wraps it inside a JSON object with a key named payload.

{ "payload": $ }

2. Select a nested value: This expression selects the location value from a nested incoming object. If the input is an object like { "user": { "name": "John", "location": "Berlin" } }, this expression will output the string "Berlin".

user.location

Visual Examples

$ sign as reference for context
JSONata function in the modifier
Object filtering with JSONata

JavaScript Expressions

This allows you to use any standard JavaScript expression that evaluates to a new value.

Examples

1. Concatenate a string: This expression takes the incoming string (x) and adds a prefix to it.

2. Perform a conditional check: This ternary expression checks if the incoming number (x) is greater than 100 and returns a corresponding string.

Visual Examples

Array filter expression in JavaScript

Patterns of common usage

  1. Changing all objects within an array at once

  2. For that the maparrow-up-right function comes in handy. Say your x represented data in the form:

    And you wanted to remove c from every entry and add a d property instead, you could write:

    This would result in the following output:

  3. Implementing full Javascript, including variables While the modifier supports only Javascript expressions, you can work around this using the IIFEarrow-up-right pattern

    This pattern is useful if you need to do something more elaborate and need a temporary variable. In case of the combine function this gets quickly useful.

  4. Computing with dates While the regulate Date object from Javascript is available, we also provide support for the extra-ordinary Luxonarrow-up-right library which provides the DateTime object. With that you can do things like:

Last updated