3 ms·
What's the common tool people use these days for manipulating json in an awk-like manner?
by tooltower 2y ago
What's the common tool people use these days for manipulating json in an awk-like manner?
- hermitcrab 2y agoProbably: https://jqlang.github.io/jq/ https://jqlang.github.io/jq/
- rmetzler 2y agoI would say that lots of people use jq. But it’s not really awk-like. You could probably use gron with awk pretty easily, since gron stands for “greppable json”. But I also wonder how an awk with native json support would look like.
- mbivert 2y agoFood for thought: have a look at this paper[0] about structural regular expressions. The author (Rob Pike) sketches in the last section an awk-support. I remember using such regexps a while ago to tweak indented JSON and JSON-like data (the indentation allowed to loop on hashes easily). An awk with json support would for the most part need to be able to loop on hashes and arrays, and provide ways to travel in-depth. So far regular awk can travel through arrays (line-separator), and "in-depth" (e.g. nested "arrays") via regular loops & cie. Probably easier to think about it with a few concrete examples though. [0]: http://doc.cat-v.org/bell_labs/structural_regexps/se.pdf http://doc.cat-v.org/bell_labs/structural_regexps/se.pdf
- sceadu 2y agogron (https://github.com/tomnomnom/gron https://github.com/tomnomnom/gron) to transform it and query and then invert the transformation?