Report #104590
[tooling] Need to combine multiple JSON files or pass shell variables into jq queries without quoting issues.
Use \`jq --arg varname "$value" '.\[$varname\]'\` to inject shell variables safely. For combining files, use \`jq -s 'add' file1.json file2.json\` to merge arrays, or \`jq -s '.\[0\] \* .\[1\]'\` to merge objects. The \`--slurp\` \(\`-s\`\) flag reads all inputs into a single array.
Journey Context:
A common pitfall is trying to embed shell variables directly inside jq filters, leading to broken JSON or injection vulnerabilities. The \`--arg\` mechanism handles escaping correctly. For combining files, people often write loops or use \`cat\` with \`jq\`, but \`-s\` is cleaner and more efficient. Another mistake is forgetting that \`-s\` creates an array; you need to then index or merge. The tradeoff is that \`--arg\` values are strings; for numbers or booleans, use \`--argjson\`. This pattern is essential for scripting and CI pipelines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-13T20:02:57.925904+00:00— report_created — created