Using XQuery to wrangle JSON
Table of Contents
Work in progress post
TODO Intro
At my work during the day to day I spend an unreasonable amount of time parsing and modifying large blobs of JSON (or, well usually it's YAML 🤮)
Because of that I try to make sure I use the right tool for the job, which is usually JQ. But as someone who's often intrigued by "obsolete" technologies I was always envious of the XML stack, the XPaths the XQueries the XLSTs…
JSON
JQ
JQ is the lingua franca of dealing with json. I don't really have any issues with it but, personally, I struggle a lot with the syntax outside of the very basics. One thing I find particularly ugly is dealing with complicated keys, eg jq '.["Key With Space Or Something IDK"]'
JMESPath
Mainly seen in AWS CLI I actually quite like JMESPath
Kubectl JSONPath
Kubectl supports JSONPath
XML
Xidel
Xidel is by far the easiest to use XQuery tool I've seen. My main issue with it is that the errors are really hard to understand
BaseX
BaseX standard library seems to be by far the most comprehensive out of all the XML tools I've seen, but I wasn't able to pass JSON to it directly, requiring a manual json:doc call
Xee
Xee is the new ✨Rust✨ XPath engine and CLI
Currently xee xpath expects a well-formed XML document as the input, which makes it unusable for us
Jee
Jee