contentintech
Tools

Jq

Inspect and reshape JSON from files and HTTP responses.

Updated Official documentation ↗

Select values

jq '.' response.jsonPretty-print valid JSON
jq '.name' response.jsonSelect a property
jq '.items[]' response.jsonEmit each item
jq -r '.name' response.jsonOutput a string without JSON quotes

Transform

jq '.items | map(.id)' response.jsonProduce an array of IDs
jq '.items[] | select(.active == true)' response.jsonKeep active items
jq '{name, id}' response.jsonBuild an object with selected properties
jq '.items | sort_by(.name)' response.jsonSort an array by a property

Variables and checks

jq --arg name 'Ada' 'select(.name == $name)' users.jsonPass a string safely
jq -e '.ok == true' response.jsonUse exit status to test a result
jq '.value // "missing"' response.jsonFallback for null or false
jq 'length' response.jsonCount array items or object keys

Section navigation