jq: Boolean to integer

If you want to replace an int with a boolean in JSON, using JQ, you can use a conditional, like so:

cat test.json | jq "if .fields.embeddable then 1 else 0 end"

JQ is much more restrictive than javascript, where you could do something like “+embeddable”.

Leave a Reply

Your email address will not be published.