Map operator
Overview
The Map operator produces an output that is an aggregation, a simplification or a rename of the output of blocks upstream in the flow.
Input variables must be defined and then mapped to keys of the output of upstream blocks: the output will be the echo of the input variables. For example, if the input variable A is mapped to the output key B of an upstream block, the output of Map will contain a key A whose value will be that of key B.
A Map block can be put downstream of any other block, but it is particularly useful at the end of a flow to easily produce an essential output, containing only what you want to come out from the workflow, so that the output JSON of the workflow itself is as compact and easy-to-parse as possible. For this reason, the Map operator is considered a post-processor.
Old version
There are two versions of the component available: the latest and 1.0.0. This version is present for backward compatibility with old workflows created with previous versions of NL Flow. For new workflows always use the latest version.
Block properties
Block properties, which are accessed by editing the block in the workflow editor, are divided in two groups:
-
Basic properties:
- Block name
- Component version (read only)
- Block ID (read only)
-
The map, that is the input variables mapped to the output keys of upstream blocks.
Defining the map
To define the map, you have to edit the block. Work in the only panel of the dialog.
-
To add a new mapping:
- Click the plus button: a new row is added below the list of existing mappings.
- In Enter key name enter a name of your choice for the input variable which doubles as an output key.
- Proceed as for setting input properties of other components' blocks.
-
To modify an existing mapping:
- Edit the left field to change the name of the input variable (output key).
- Use the drop-down as described above if you want to change the source key.
-
To remove an existing mapping, select Remove to the right of it.
When done, select Confirm.
Output
The output of a Map block is a JSON object containing the results of the mapping. Its structure is as follows:
{
First key: value of the corresponding output key of the upstream block
Second key: value of the corresponding output key of the upstream block
...
Last key: value of the corresponding output key of the upstream block
}
If an input variable cannot be set when the workflow is executed because the corresponding source is missing, the output key will be set to null
.