jq cheatsheet
My jq
cheatsheet:
Access the top level:
jq .
Pretty print:
jq -r .
List the top-level keys:
jq -r ".|= keys'
Access an object key:
jq .keyname
Access an array element:
jq .[n]
Access an array range:
jq .[n:m]
jq .[n:]
jq .[:m]
Access multiple object values:
jq '.first, .second'
Access a value then filter:
jq '.[n] | .first, .second'
Map an array
jq 'map(...)'
- https://github.com/rjz/jq-tutorial