Map operator
Overview
The Map operator produces its output by using only selected parts of its input.
The correspondence between input parts and corresponding output parts is called mapping, hence the name of the operator.
The Map operator can be used everywhere and is particularly useful after a Join block to create a "compact" version of its composite output as the final output of the workflow or as the input to further blocks. For this reason, Map operator can be 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:
-
Functional: the definition of the input-output map.
-
Output: list of output properties (read-only)
-
Basic properties:
- Block name
- Component version (read only)
- Block ID (read only)
-
Input-Output map: the map between inputs and properties of the output JSON. See below how to define it.
Defining the map
To define the input-output map, you have to edit the block.
-
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 output key.
-
Using the drop-down choose a the corresponding input key from the list of the output keys of the upstream blocks.
The list is divided in groups, one group for each upstream block. Select the name of the block multiple times or the expand and collapse icons to the right of the block name to show or hide the sub-list of output keys for that block.
The first entry in the sub-list is the block name.By choosing it, the corresponding output key of the Map block will be an object whose value is the entire output of the chosen input block.
Note
The drop-down list shows all the first-level keys that can, potentially, be available, but the keys that are actually there when executing the workflow may be less. If you map a key that's not actually produced at runtime, the corresponding output object will be set to
null
.You can filter the list by typing at the top of it: the list will show only keys with matching names.
To cancel the mapping process, select No mapping from the list or, if you already chose a key, select Clear .
-
To modify an existing mapping:
- Edit the left field to change the name of the output key.
- Use the drop-down as described above to choose a different input 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: Corresponding input property
Second key: Corresponding input property
...
Last key: Corresponding input property
}
If a mapped input property is missing at run time, the corresponding output object will be set to null
.