How to filter array of objects by element property values using jq?

From the docs:

jq '.[] | select(.id == "second")' 

Input [{"id": "first", "val": 1}, {"id": "second", "val": 2}]

Output {"id": "second", "val": 2}

I think you can do something like this:

jq '.theList[] | select(.id == 2 or .id == 4)' array.json

Leave a Comment