7 ms·
Just recently used xq to convert and clean up a bunch of weird xml files to JSON. It was such a breeze. I love how nested lists inside objects can expand into
by labelbias 6y ago
Just recently used xq to convert and clean up a bunch of weird xml files to JSON. It was such a breeze.
I love how nested lists inside objects can expand into a particular one with the .[] operator.
For example:
{ a: [{b: 5}, {b: 3}], c: 5} can be transformed into:
[{ b: 5, c: 5}, {b: 3, c: 5}] using jq '{c: .c, b: .a[].b}'
For heavily nested XMLs I can get a nice flat output.
- code-faster 6y agoNice! I've found xml transforms is one of the best applications of jq (yes, jq, not xq). In a future post, I'll cover how to use jq not just for json and xml but any data format.