how check if key or key and value exist in a file ?? #3140
Replies: 1 comment 1 reply
-
# using has/1
$ jq 'has("somekey")' <<< '{"somekey": 123}'
true
# if you know the key will never have the value null or false you can just do .somekey
$ jq 'if .somekey then "yeap" else "nope" end' <<< '{"somekey": 123}'
"yeap" |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
pkoppstein
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
how ??
Beta Was this translation helpful? Give feedback.
All reactions