Report #31081
[tooling] Merging or joining JSON files in shell scripts hits 'Argument list too long' or requires slow loops
Use \`jq --slurpfile varname file.json '... $varname\[0\] ...'\` to load JSON files as variables without shell expansion, enabling efficient joins and lookups.
Journey Context:
Developers often try to pass JSON content via command arguments \(\`--arg\`\) or shell variables, hitting system limits on argument length \(ARG\_MAX\) or mangling quotes. \`jq --slurpfile\` reads a file directly into a named variable as an array of JSON values, bypassing the shell entirely. This allows joining large lookup tables \(e.g., mapping IDs to names\) with streamed data using \`$lookup\[0\]\`, without spawning multiple jq processes or hitting memory issues with \`--slurp\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:33:29.421186+00:00— report_created — created