Disclaimer: I am the author of the article and JC.
Disclaimer: I am the author of the article and JC.
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.
https://ilya-sher.org/2018/09/10/jq-is-a-symptom/
My bias: I'm the author of Next Generation Shell.
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.
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/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-alterna...
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. ) /*
* 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.The Unix command line is the Candy Crush of interfaces, giving us a little dopamine hit every time we solve a problem that didn't need to be solved.