Select objects based on value of variable in object using jq

The Solution to Select objects based on value of variable in object using jq is


Adapted from this post on Processing JSON with jq, you can use the select(bool) like this:

$ jq '.[] | select(.location=="Stockholm")' json
{
  "location": "Stockholm",
  "name": "Walt"
}
{
  "location": "Stockholm",
  "name": "Donald"
}

~ Answered on 2013-09-04 07:42:01


Most Viewed Questions: