Report #17609
[tooling] Shell scripts parsing JSON with Python/Node are slow, have injection risks, or fail on large files
Use \`jq --arg name "$VAR" --slurpfile items items.json '. \+ \{name: $name, items: $items\[\]\}'\` to safely inject shell variables and compose multiple JSON sources
Journey Context:
Using \`python -c "import json..."\` in shell scripts breaks on quote escaping and lacks error handling. jq's \`--arg\` safely encodes shell strings as JSON strings, preventing injection. \`--argjson\` parses the value as JSON \(numbers/booleans\). For large files, \`--slurp\` reads all inputs into an array, but \`--stream\` parses incrementally enabling processing of multi-GB files with constant memory. \`--slurpfile\` reads a file into a variable, avoiding shell command substitution limits. This is the robust standard for JSON in shell pipelines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:50:52.058537+00:00— report_created — created