4 ms·
Output data as JSON, manipulate and show it with jq
by kuschku 7y ago
Output data as JSON, manipulate and show it with jq
- bryanrasmussen 7y agonot all data comes from sources that you control and have chosen how to output.
- BaltoRouberol 7y agohttps://github.com/kellyjonbrazil/jc https://github.com/kellyjonbrazil/jc can come pretty handy there
- bryanrasmussen 7y agothanks!
- enriquto 7y agooh my god, why?! just why!? What the world needs is the inverse program of "jc", where an unparseable json string is expanded into a flat list of lines all of the form "field.subfield=value"
- bryanrasmussen 7y agook well I can understand not wanting json when all you need is something simpler, but I'm not sure if I understand unparseable - I mean if it is JSON then it is parseable.
- enriquto 7y agoYou can only parse json easily by using json libraries. Plain text, or "field=value" pairs, you can easily cut(1) or grep(1), or sed(1) to your pleasure. This is what I mean by parseable. Parseable trivially by tools that do not understand the format. I can also sed and awk json files, and I do, but it is extremely painful; and more often than not these files are nothing more than simple lists of variables with values, for which the use of json is a ridiculous overkill.
- bryanrasmussen 7y agoOk, but I believe that your use of the word parseable diverges quite a bit from common usage.
- Igrom 7y agoIf you search for "gron", you will find a family of such tools, e.g., https://github.com/tailhook/rust-gron https://github.com/tailhook/rust-gron.
- enriquto 7y agoThanks, that's just what I needed!
- enriquto 7y agoI hate jq with the power of a million suns. The whole point of text through pipelines is that data can be processed by tools that do not understand it. Formatting it in xml or json (there's no difference) breaks this beautiful orthogonality, and forces all the intermediate tools to deal with whatever the stupid markup du jour happens to be.