Report #63987
[tooling] Merging multiple JSON files into one array or object requires fragile shell loops
Use \`jq -n '\[inputs\]' file1.json file2.json\` to concatenate all input files into a single JSON array, or \`jq -s 'add' \*.json\` to merge objects. The \`-n\` \(null input\) flag prevents reading stdin, letting \`inputs\` read all file arguments explicitly.
Journey Context:
The common mistake is \`cat \*.json \| jq -s .\` which forces unnecessary string concatenation and risks argument list length limits. \`jq -n '\[inputs\]'\` uses the \`-n\` flag to start with \`null\`, then the \`inputs\` builtin reads all remaining file arguments as separate JSON values. This is more explicit and memory-efficient for large file lists. For merging objects \(like config files\), \`jq -s 'add'\` slurps inputs into an array then adds them, with rightmost values winning.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T13:53:30.948273+00:00— report_created — created