Modifier

The modifier is a very simple but powerful tool for on-the-fly data modification and transformation using code. It falls under the category of function extensions. Adding and deleting modifiers follows the same process as with the other extensions. Click the + icon behind an output, modifier, filter, or error handler, and choose the Modifier option.

Working with modifiers

Modifiers work akin to output, enabling you to leverage their value by linking to another function or a widget. The modifiers value is recalculated from the previous value after every trigger. The previous value can originate from an output, an error handler, a filter, or another modifier.

You can incorporate as many consecutive modifiers as needed.

To execute two or more independent modifications for the same output value, you can use the parallel modifier:

  1. Click the + icon behind a modifier

  2. Select Parallel Modifier

You can add as many parallel modifiers as required for your specific needs.

Types

There are JSONata and JavaScript expression modifiers. By default, a modifier is set to JSONata.

The choice between JavaScript and JSONata often depends on your programming background. JavaScript may be more comfortable for those familiar with programming, while JSONata can be easier for beginners.

To switch between JSONata and JavaScript:

  1. Right-click on an existing modifier

  2. Select Jsonata for JSONata or Expression for JavaScript

When switching the modifier type, its content is deleted.

JSONata

JSONata is a lightweight query and transformation language tailored for JSON data, and it has been seamlessly integrated into Heisenware. This integration is due to JSONata's support for sophisticated query expressions with minimal syntax, as well as its built-in operators and functions for efficiently manipulating and combining data.

The JSONata documentation and the exerciser are the best way to familiarize yourself with JSONata and its possibilities.

Only two essential and frequently used aspects of will be discussed here.

Referencing

To refer to the value of a previous box, whether it's an output or a modifier itself, utilize 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.

Filtering objects

JSONata simplifies the task of filtering JSON objects significantly. You can achieve this by specifying a key in the modifier to filter it from an object.

JavaScript expression

A JavaScript expression is a unit of code that evaluates to a value. The modifier allows the use of evaluation expressions and integrates them seamlessly.

The variable x contains the value of the preceding output or the preceding modifier, and it should not be used for any other purpose.

The expressions and operators documentation for JavaScript is a great starting point to get to know all the possibilities the modifier features has in store for you.

Pro tip: Immediately Invoked Function Expressions (IIFE) are supported as well.

Last updated