jq Cheatsheet
Select
The format is:
... | jq '<filter> | select(<condition>)' | ...
Select objects where a specific field equals a value:
jq '.[] | select(.id == 101)'
Select objects based on multiple conditions
jq '.[] | select(.status == "active" and .count > 5)'
Select items that match a value in a nested array
jq '.[] | select(.tags[] == "urgent")'
Select based on the presence of a key
`jq '.[] | select(has("optional_field"))'
Select specific data from filtered objects
jq -r '.files[] | select(.fileName=="FOO")'
Select with contains
jq -r '.files[] | select(.<field> | contains("<value>")'