4 ms·
This is even more true for the ungodly long `jq` incantations that people write. It's like I get it, the old way is ugly and not always easy to decipher but at
by pdimitar 5y ago
This is even more true for the ungodly long `jq` incantations that people write.
It's like I get it, the old way is ugly and not always easy to decipher but at least it's shorter and your chances of understanding it are better.
I've had both -- the classic piped chain of UNIX commands and various JSON-producing tools piped to `jq`. The former were still easier to work with.
- kbrazil 5y agoYes, I have seen those too! That’s why I also wrote Jello, which is like jq but uses pure python without the boilerplate. Python is nearly universal now and typically easy to read, though more verbose. Jq is just as much a write-once tool as awk and perl for more complex queries. For simple attribute calls, though, it’s both terse and readable.
- NegativeLatency 5y agoI wrote something similar by description in ruby, I’d be curious to see your python implementation. I considered python but Ruby’s easier chaining with map/filter/etc made it easier for me to use when writing just one line with it to transform some json. https://github.com/nburns/utilities/blob/master/rson https://github.com/nburns/utilities/blob/master/rson
- kbrazil 5y agoSure thing! https://github.com/kellyjonbrazil/jello https://github.com/kellyjonbrazil/jello Other languages are superior in their handling of maps/arrays, but Python is just so damned popular now I thought it was a good choice to democratize JSON handling. https://blog.kellybrazil.com/2020/03/25/jello-the-jq-alternative-for-pythonistas/ https://blog.kellybrazil.com/2020/03/25/jello-the-jq-alterna...
- hnlmorg 5y agoThis is why I wrote murex shell (https://github.com/lmorg/murex https://github.com/lmorg/murex), it's an alternative $SHELL, so you'd use it in place of Bash or Zsh, but it's optimised for modern DevOps tools. Which means JSON and YAML are first class citizens. It's syntax isn't 100% POSIX compatible so there is some new stuff to learn but it works with all the existing POSIX tools and is more readable than AWK and Perl but while also being terse enough to write one liners.
- hackerbrother 5y ago(Sorry, this is my first time trying to do a formatted comment here.) What I like to do is comments like: /* * Collates * [ * { * id: 4 * dept: 'oncology', * name: 'Joe S.' * } * . * . * . * ] * * into * * { * 4: { // id * 'Joe. S': { // name * dept: oncology * } * . * . * . * } */ ( Then insert horrible one-liner that does the transformation. )
- deleted 5y ago[deleted]
- Jtsummers 5y agoTwo spaces in front of a line will create a code block: /* * Collates * [ ... Removes all the unneeded vertical space created by inserting the extra newlines and makes the entire thing more readable. Put two spaces in front of each line that will be part of the code block and then any extra needed spaces. Some text editors can format text in this manner automatically for you.
- ilyash 5y agoOpinion: Today's shells should have structured data; `jq` is a symptom of a shell that can't handle structured data. https://ilya-sher.org/2018/09/10/jq-is-a-symptom/ https://ilya-sher.org/2018/09/10/jq-is-a-symptom/ My bias: I'm the author of Next Generation Shell.