Report #27288
[tooling] Processing multiple JSON objects or streaming input as a cohesive array for transformation
Use jq -s \(slurp\) to read all JSON inputs into an array, then apply map/select operations to transform the entire dataset, enabling aggregation and filtering across multiple objects
Journey Context:
By default, jq processes JSON objects individually \(streaming mode\), which makes operations like 'find all objects where field X > 5 and return the average of field Y' impossible to express cleanly across multiple objects. The -s \(--slurp\) flag reads all input into a single array, allowing standard functional operations \(map, filter, reduce, group\_by\). This is essential for processing ndjson \(newline-delimited JSON\) files, log streams, or API pagination results. Common pattern: jq -s 'map\(select\(.status == 200\)\) \| length' to count successful requests. Without -s, you'd need complex recursion or reduce patterns. Note: -s loads everything into memory, so not suitable for unbounded streams without splitting.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:12:04.049619+00:00— report_created — created