Skip to main content

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

InputTypeDescriptionDefault
ListDataThe array of items to transform. If not an array or empty, returns the input unchanged.-
PatternCode (JSON)A JSON template string containing Handlebars placeholders (e.g., {"item": {{value}}, "idx": {{index}}}).-
DynamicDataAny Handlebars variables referenced in the pattern (excluding value and index) appear as additional inputs.-
Dynamic 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

OutputTypeDescription
OutputDataThe transformed list containing the result of applying the pattern to each input element.

Runtime Behavior

When executed, the node performs the following operations:

  1. Validation: Checks if the input is a valid array. If not, returns the original input unchanged.
  2. Iteration: Loops through each element of the input list.
  3. Variable Substitution: For each element, creates a context with:
    • value: The current list element
    • index: The current index (0-based)
    • All workflow variables, parent variables, and connected inputs
  4. JSON Parsing: Parses the pattern string with variables substituted to create the output element.
  5. 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).