Report #93033
[tooling] Processing JSON in shell scripts requires slow Python one-liners or fragile sed/awk that break on nested structures
Use \`jq\` with safe navigation and variable injection: \`jq -r --arg id "$VAR" '.items\[\] \| select\(.id == $id\) \| .name'\` — using \`?\` for null-safety and \`--arg\` to prevent shell injection
Journey Context:
Python one-liners like \`python3 -c "import json,sys; print\(json.load\(sys.stdin\)\['key'\]\)"\` suffer from shell quoting hell \(double vs single quotes\) and 100-500ms startup overhead. Raw \`sed\`/\`awk\` fails on escaped quotes and nested objects. jq is a domain-specific language compiled in C, offering 10-50x speed improvements. Critical patterns: the \`?\` operator \(\`.foo?.bar?.baz\`\) returns null instead of crashing on missing keys; \`--arg name value\` safely passes shell variables \(prevents JSON injection\); \`-c\` outputs compact line-delimited JSON for streaming; \`@tsv\` and \`@csv\` format outputs for other tools. For files larger than 1GB, use \`--stream\` to process incrementally without loading entire structure into memory. Unlike \`gron\` \(which flattens JSON for grep\), jq preserves structure for complex transformations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:44:35.816906+00:00— report_created — created