JSON List Processor¶
Processes each item of a JSON array concurrently using user-provided Python logic. It captures outputs and warnings per item, aggregates results into a JSON string, and reports a structured execution log with success and failure counts. Designed for fast, parallel transformations of list-based JSON data.

Usage¶
Use this node when you have a JSON array (e.g., from an API or a previous node) and need to apply the same transformation to each item. Provide the JSON list and a Python snippet that reads the current item via 'input_data' and sets a result. Configure worker count for concurrency and set a per-item timeout. Typical workflow: fetch or generate JSON list -> JSON List Processor -> downstream analysis or storage.
Inputs¶
| Field | Required | Type | Description | Example |
|---|---|---|---|---|
| json_list | True | STRING | A JSON-formatted array of items to process. Must be a valid JSON list (top-level array). Each element is passed to the code as 'input_data'. | [{"id":1,"title":"Example"},{"id":2,"title":"Another"}] |
| python_code | True | STRING | Python code that processes a single item. Access the current item via 'input_data' and set 'result' (or return a value) to produce the output for that item. Variables available: input_data, input_index, all_inputs, logger. | # Use 'input_data' and set 'result' accordingly |
| max_workers | True | INT | Number of concurrent workers used to process items in parallel. | 4 |
| timeout_seconds | True | FLOAT | Maximum allowed execution time per item. Items exceeding this timeout are marked as timed out. | 30.0 |
Outputs¶
| Field | Type | Description | Example |
|---|---|---|---|
| results_json | STRING | A JSON string representing a list of per-item results in the order tasks complete. Items that failed or timed out may be null depending on error handling. | [{"processed":true}, {"processed":true}, null] |
| execution_log | STRING | A newline-separated log of per-item execution outcomes, including stdout, warnings, errors, and a final summary. | Item 0: SUCCESS \| Output: ...\nItem 1: ERROR - ...\nProcessed 10 items. Success: 9, Failed: 1 |
| success_count | INT | Number of items that executed successfully. | 9 |
| total_items | INT | Total number of items provided in the input JSON list. | 10 |
Important Notes¶
- The input must be a valid JSON array (top-level list). Objects or invalid JSON will be rejected.
- The code runs in a restricted environment. Disallowed patterns include: import os, import sys, import subprocess, import shutil, exec(, eval(, import, open(, file(, input(, raw_input(, compile(). If detected, the code is rejected.
- Available variables in your code: input_data (current item), input_index (0-based), all_inputs (the entire list), logger (for logging).
- You can set 'result' (or return a value) in the code to produce the per-item output.
- Execution is concurrent using multiple workers. The 'results_json' list reflects completion order, not the original input order.
- Per-item stdout and stderr are captured and summarized in the execution log.
- Per-item timeout applies. Timed-out items are logged as TIMEOUT and produce a null result.
- If a result cannot be serialized to JSON, it is converted to a string with a warning appended to the execution log.
Troubleshooting¶
- Invalid JSON format: Ensure 'json_list' is a valid JSON array string. If you see 'Invalid JSON format', validate the JSON and remove trailing commas or malformed entries.
- Input is not an array: Supply a top-level JSON list (e.g., [{...}, {...}]). Objects like {"a":1} are not accepted.
- Invalid Python code provided: Remove disallowed patterns and fix syntax errors. Keep logic self-contained and avoid imports that are blocked.
- Item timeouts: Increase 'timeout_seconds' or reduce workload per item if you see 'TIMEOUT' messages.
- Unexpected nulls in results: Items that failed or timed out produce null. Review 'execution_log' for the specific item’s error or exception details.
- Serialization warnings: If complex objects appear in results, convert them to primitive types or strings in your code to avoid JSON serialization issues.