{"id":991,"date":"2014-05-24T05:19:52","date_gmt":"2014-05-24T11:19:52","guid":{"rendered":"http:\/\/jaredrobinson.com\/blog\/?p=991"},"modified":"2014-05-24T05:19:52","modified_gmt":"2014-05-24T11:19:52","slug":"jq-sedgrep-like-tool-for-processing-json-data","status":"publish","type":"post","link":"https:\/\/jaredrobinson.com\/blog\/jq-sedgrep-like-tool-for-processing-json-data\/","title":{"rendered":"jq: sed\/grep-like tool for processing JSON data"},"content":{"rendered":"<p>The other day I was exporting json data from mongodb using <a href=\"http:\/\/docs.mongodb.org\/v2.2\/reference\/mongoexport\/\">mongoexport<\/a>, and needed a way to exclude certain subdocument fields. mongoexport doesn&#8217;t support excluding fields.<\/p>\n<p><a href=\"http:\/\/stedolan.github.io\/jq\/\">jq<\/a> saved the day.<\/p>\n<p>I piped the output of mongoexport through jq, and piped the output of that to gzip. My pipeline looks like this:<\/p>\n<p>nice mongoexport &#8211;db mydb &#8211;collection accounts &#8211;out &#8211; | nice jq -c -M &#8216;del(.phash) | del(.h[].phash)&#8217; | nice gzip > accounts.json.gz<\/p>\n<p>Whoever wrote <a href=\"http:\/\/stedolan.github.io\/jq\/\">jq<\/a>, thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The other day I was exporting json data from mongodb using mongoexport, and needed a way to exclude certain subdocument fields. mongoexport doesn&#8217;t support excluding fields. jq saved the day. I piped the output of mongoexport through jq, and piped the output of that to gzip. My pipeline looks like this: nice mongoexport &#8211;db mydb &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/jaredrobinson.com\/blog\/jq-sedgrep-like-tool-for-processing-json-data\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;jq: sed\/grep-like tool for processing JSON data&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-991","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/comments?post=991"}],"version-history":[{"count":3,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/991\/revisions"}],"predecessor-version":[{"id":998,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/991\/revisions\/998"}],"wp:attachment":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/media?parent=991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/categories?post=991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/tags?post=991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}