get the first (or n’th) element in a jq json parsing

You can wrap the results from select in an array:

jq '[.[]|select(.a=="x")][0]' your.json

Output:

{
  "a": "x",
  "b": false
}

Leave a Comment