OurBigBook About$ Donate
 Sign in Sign up

jq ignore missing attribute

Ciro Santilli (@cirosantilli, 37) ... Information technology Computer File format Data file format JSON jq
Updated 2025-07-16  0 By others on same topic  0 Discussions Create my own version
echo '[{"a": 1, "b": 2}, {"b": 3}]' | jq '.[] | select(.a) | .a'
Output:
1
and no empty lines as desired.
Bibliography:
  • stackoverflow.com/questions/42097410/how-to-check-for-presence-of-key-in-jq-before-iterating-over-the-values

 Ancestors (9)

  1. jq
  2. JSON
  3. Data file format
  4. File format
  5. Computer
  6. Information technology
  7. Area of technology
  8. Technology
  9.  Home

 View article source

 Discussion (0)

New discussion

There are no discussions about this article yet.

 Articles by others on the same topic (0)

There are currently no matching articles.
  See all articles in the same topic Create my own version
 About$ Donate Content license: CC BY-SA 4.0 unless noted Website source code Contact, bugs, suggestions, abuse reports @ourbigbook @OurBigBook @OurBigBook