{"id":38048,"date":"2023-01-03T16:43:52","date_gmt":"2023-01-03T21:43:52","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=38048"},"modified":"2023-01-05T16:11:41","modified_gmt":"2023-01-05T21:11:41","slug":"jq-and-xmlstarlet","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2023\/01\/03\/jq-and-xmlstarlet\/","title":{"rendered":"jq and XmlStarlet"},"content":{"rendered":"<p><a href=\"https:\/\/stedolan.github.io\/jq\/\">jq<\/a>:<\/p>\n<blockquote cite=\"https:\/\/stedolan.github.io\/jq\/\"><p>jq is like <code>sed<\/code> for JSON data - you can use it to slice and filter\nand map and transform structured data with the same ease that <code>sed<\/code>,\n<code>awk<\/code>, <code>grep<\/code> and friends let you play with text.<\/p><p>[&#8230;]<\/p><p>jq can mangle the data format that you have into the one that you want with very little effort, and the program to do so is often shorter and simpler than you&rsquo;d expect.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/xmlstar.sourceforge.net\/overview.php\">XmlStarlet<\/a>:<\/p>\n<blockquote cite=\"https:\/\/xmlstar.sourceforge.net\/overview.php\"><p>XMLStarlet is a set of command line utilities (tools) which can be used to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc commands.<\/p><\/blockquote>\n\n<p>Via <a href=\"https:\/\/mastodon.social\/@helge\/109608120364812913\">Helge He&szlig;<\/a>:<\/p>\n<blockquote cite=\"https:\/\/mastodon.social\/@helge\/109608120364812913\"><p>Handy if you have to read and modify XML files from within shell scripts in a reliable way (i.e. w\/o a regex mess &#x1F643;).<\/p><\/blockquote>\n\n<p id=\"jq-and-xmlstarlet-update-2023-01-05\">Update (2023-01-05): <a href=\"https:\/\/mastodon.social\/@doekman@mastodon.nl\/109629934038753400\">doekman<\/a>:<\/p>\n<blockquote cite=\"https:\/\/mastodon.social\/@doekman@mastodon.nl\/109629934038753400\">\n<p>Did you know there is also an <a href=\"https:\/\/github.com\/sibprogrammer\/xq\">xq<\/a>? Not as feature rich as XmlStarlet, but I find it much more approachable (assuming you know xpath)<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>jq: jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text.[&#8230;]jq can mangle the data format that you have into the one that you want with very little [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2023-01-03T21:43:54Z","apple_news_api_id":"39f1f992-ff6e-45c9-9c4d-6bed887c690f","apple_news_api_modified_at":"2023-01-05T21:11:51Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/AOfH5kv9uRcmcTWvtiHxpDw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[507,74,71,866],"class_list":["post-38048","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-json","tag-opensource","tag-programming","tag-xml"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/38048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=38048"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/38048\/revisions"}],"predecessor-version":[{"id":38075,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/38048\/revisions\/38075"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=38048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=38048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=38048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}