Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jq - How to select objects where a field is 'false'?

Tags:

boolean

jq

I'm having trouble implementing boolean checks into jq. If I have a field "test" which can be a boolean true or false, how do I use select to find this?

Initially I tried the following:

jq '.[] | select(.test=="false")'

But I think I am comparing strings here so this will not work.

like image 497
x3nr0s Avatar asked Jul 04 '16 14:07

x3nr0s


1 Answers

The JSON boolean values are true and false, so just drop the quotation marks, e.g. select(.test == false).

like image 85
peak Avatar answered Oct 12 '22 00:10

peak