Since .value
is true
, which does not have an field message
, I thought .message?
should be evaluated to false
. Then “Y” should be printed. Can you help me understand why neither “X” nor “Y” is printed?
$ jq '.value|if .message? then "X" else "Y" end' <<< '{"value":true}'
How to revise the code so that if “message” is a field of the value of .value
, then print “X”, otherwise print “Y”?