Map List
Uncontrolled node
Overview
The Map List node transforms each element of an input list by applying a JSON pattern template. It iterates through the input array, substitutes the current element and index into the pattern, and produces a new list containing the transformed results.
This node uses Handlebars-style variable substitution (double curly braces {{}}) within a JSON structure. For each iteration, {{value}} represents the current list element and {{index}} represents its position (0-based). Additional variables from connected inputs can also be referenced in the pattern.
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| List | Data | The array of items to transform. If not an array or empty, returns the input unchanged. | - |
| Pattern | Code (JSON) | A JSON template string containing Handlebars placeholders (e.g., {"item": {{value}}, "idx": {{index}}}). | - |
| Dynamic | Data | Any Handlebars variables referenced in the pattern (excluding value and index) appear as additional inputs. | - |
The node automatically detects variables in your pattern. For example, if your pattern contains {{multiplier}}, a corresponding input socket named multiplier will appear on the node.
Outputs
| Output | Type | Description |
|---|---|---|
| Output | Data | The transformed list containing the result of applying the pattern to each input element. |
Runtime Behavior
When executed, the node performs the following operations:
- Validation: Checks if the input is a valid array. If not, returns the original input unchanged.
- Iteration: Loops through each element of the input list.
- Variable Substitution: For each element, creates a context with:
value: The current list elementindex: The current index (0-based)- All workflow variables, parent variables, and connected inputs
- JSON Parsing: Parses the pattern string with variables substituted to create the output element.
- Output: Collects all transformed elements into a new list.
If the pattern is empty, invalid JSON, or parsing fails, the node returns the original list unchanged.
Example
Input List: [10, 20, 30]
Pattern: {"original": {{value}}, "doubled": {{multiply value 2}}, "position": {{index}}}
Additional Input: A multiply function or value (if using external variables)
Output:
[
{"original": 10, "doubled": 20, "position": 0},
{"original": 20, "doubled": 40, "position": 1},
{"original": 30, "doubled": 60, "position": 2}
]
Simple Property Access Example:
To extract a specific property from a list of objects, use:
{"name": "{{value.name}}", "id": {{value.id}}}
This would transform [{"name": "Alice", "id": 1}, {"name": "Bob", "id": 2}] into [{"name": "Alice", "id": 1}, {"name": "Bob", "id": 2}] (restructured according to the pattern).