Using jq to extract values in JSON array with a particular key boolean == true?

Viewed 22773

So I have a JSON blob as below:

[
  {
    'id': 'something',
    'isSparse': true
  },
  ...
]

How do I write a jq command that'll filter out this JSON blob and print me the IDs of all entries in the array that have isSparse == true?

I tried the following:

cat <blob> | jq -c '.[] | select(.operational | contains("true"))'

but get the following, because obviously true is a boolean and not a string:

jq: error: boolean and string cannot have their containment checked.

3 Answers
Related