{"id":5873,"date":"2018-11-04T19:41:56","date_gmt":"2018-11-04T19:41:56","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=5873"},"modified":"2018-11-04T19:41:56","modified_gmt":"2018-11-04T19:41:56","slug":"jq-boolean-integer","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/jq-boolean-integer\/","title":{"rendered":"jq: Boolean to integer"},"content":{"rendered":"<p>If you want to replace an int with a boolean in JSON, using JQ, you can use a conditional, like so:<\/p>\n<pre>\ncat test.json | jq \"if .fields.embeddable then 1 else 0 end\"\n<\/pre>\n<p>JQ is much more restrictive than javascript, where you could do something like &#8220;+embeddable&#8221;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Convert a boolean to an int with jq<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[302,312,322],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/5873"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=5873"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/5873\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=5873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=5873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=5873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}