Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

Why neither branch of if-statement is reached?

$
0
0

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"?


Viewing all articles
Browse latest Browse all 657

Trending Articles