jq
TLDR
Pretty print JSON
$ cat [data.json] | jq '.'
Extract field$ cat [data.json] | jq '.name'
Array indexing$ cat [data.json] | jq '.[0]'
Filter array$ cat [data.json] | jq '.[] | select(.age > 30)'
Map transformation$ cat [data.json] | jq '[.[] | {name, age}]'
Raw string output$ cat [data.json] | jq -r '.name'
Compact output$ cat [data.json] | jq -c '.'
SYNOPSIS
jq [options] filter [file...]
DESCRIPTION
jq is a command-line JSON processor. It filters, transforms, and formats JSON data.
The tool uses a powerful query language for JSON manipulation. It supports complex transformations and data extraction.
jq processes and transforms JSON.
PARAMETERS
FILTER
jq filter expression.FILE
Input JSON file(s).-r, --raw-output
Output raw strings.-c, --compact-output
Compact output.-s, --slurp
Read entire input as array.-n, --null-input
No input.--arg NAME VAL
Set variable.--help
Display help information.
CAVEATS
Learning curve for complex queries. Streaming mode for large files. Null handling can be tricky.
HISTORY
jq was created by Stephen Dolan as a sed/awk equivalent for JSON, becoming the standard CLI JSON tool.


