Skip to content

JSON Loop Open

Starts a loop over a JSON array and emits the current item for each iteration. It maintains loop state in a LOOP object and passes through up to four auxiliary values so they can be preserved or updated across iterations.
Preview

Usage

Use this node to iterate over a JSON array and process each item in sequence. Connect its LOOP output to a JSON Loop Close node to drive iteration. Provide a JSON array in json_list, optionally gate iteration with a boolean condition, and use aux channels to carry state between iterations. The loop advances when the Close node triggers the next iteration.

Inputs

FieldRequiredTypeDescriptionExample
json_listTrueSTRINGThe JSON array to iterate over. Accepts a JSON string representing an array or a pre-parsed list provided by an upstream node.[{"id":1,"active":true},{"id":2,"active":false}]
conditionTrueSTRINGA boolean expression (as text) that controls whether the current iteration should proceed. If it evaluates to false, the loop will finalize on the Close node. Useful variables include: current_item, current_index, total_items.current_index < total_items and (current_item.get('active', False) == True)
index_overrideFalseANYManually sets the current index for the loop (0-based). Use to resume or jump within the JSON array.0
auxFalseANYPrimary auxiliary value to pass through each iteration (e.g., an accumulator or context object).{"sum": 0}
aux2FalseANYSecondary auxiliary value passed through each iteration.["log entry 1"]
aux3FalseANYTertiary auxiliary value passed through each iteration.true
aux4FalseANYQuaternary auxiliary value passed through each iteration.42

Outputs

FieldTypeDescriptionExample
LOOPANYLoop state dictionary containing information like id, index, total_items, finished, and internal linkage. Connect this to the LOOP input of a JSON Loop Close node.{"id": "", "index": 0, "total_items": 3, "finished": false}
current_itemANYThe current element from the JSON array for this iteration.{"id":1,"active":true}
auxANYPassthrough of the aux value for this iteration.{"sum": 10}
aux2ANYPassthrough of the aux2 value for this iteration.["log entry 1","log entry 2"]
aux3ANYPassthrough of the aux3 value for this iteration.false
aux4ANYPassthrough of the aux4 value for this iteration.99

Important Notes

  • Condition defaults to True: If left empty or non-boolean, it is treated as True. Provide a valid boolean expression as text.
  • End-of-list or failed condition: When the index reaches the end of the list or the condition evaluates to false, only the LOOP state is updated for finalization and the JSON Loop Close node will output FINISHED? = True.
  • Auxiliary passthrough: Up to four aux values (aux, aux2, aux3, aux4) are carried across iterations; connect them to the Close node to preserve/update state.
  • Indexing: index_override is 0-based. Negative or invalid values are sanitized to 0.
  • Input format: json_list should represent an array (e.g., [1,2,3]). Objects or invalid JSON will not iterate.
  • Pairing required: This node must be paired with JSON Loop Close to advance iterations and detect completion.

Troubleshooting

  • Invalid JSON in json_list: Ensure json_list is a valid JSON array string (e.g., "[1,2,3]") or provide a list from an upstream node.
  • Condition errors: If the condition references missing variables or is not a valid boolean expression, iteration will not proceed. Use variables like current_item, current_index, and total_items.
  • Loop never finishes: Verify the LOOP output is connected to a JSON Loop Close node and that the condition will eventually become false or the index reaches the end.
  • No current_item output: This is expected when the loop is finalizing (end of list or condition false). Check the Close node for FINISHED? status.
  • Unexpected index: If iteration restarts at 0, ensure index_override is an integer and is being set correctly from the Close node when continuing.