OurBigBook
About
$
Donate
Sign in
+
Sign up
jq ignore missing attribute
New to
topics
?
Read the documentation here!
Top articles
Latest articles
+
New article in topic
Show body
Body
0
jq ignore missing attribute
by
Ciro Santilli
34
Updated
2024-12-15
+
Created
1970-01-01
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
Total
articles
:
1