Convert array to object (index_by) jq
Build an object keyed by the id field
jq 'INDEX(.[]; .id)' items.json
more jq
all 17 commands →
Merge two objects
jq -s '.[0] * .[1]' base.json override.json
Extract nested value safely
jq '.config?.database?.host // "localhost"' config.json
Sort by numeric field
jq 'sort_by(.timestamp) | reverse | .[0:5]' events.json
Convert JSON to CSV
jq -r '.[] | [.id, .name, .status] | @csv' data.json
Add field to every element
jq '[.[] | . + {"env": "prod"}]' items.json