jq

Pretty print and query JSON data from the command line.

brewmacoslinux
Try with needOr install directly
Source

About

Lightweight and flexible command-line JSON processor. Pretty print JSON, parse and query JSON data, filter and transform JSON on the command line.

Commands

jq

Examples

pretty print JSON in terminal$ echo '{"name":"john","age":30}' | jq
extract a specific field from JSON$ echo '{"name":"john","age":30}' | jq '.name'
filter JSON array by condition$ echo '[{"name":"john","age":30},{"name":"jane","age":25}]' | jq '.[] | select(.age > 26)'
transform JSON structure$ echo '{"first":"john","last":"doe"}' | jq '{name: (.first + " " + .last)}'
parse JSON from file and count array elements$ jq 'length' data.json