Oh no. This looks like the horrible config format a colleague of mine invented at Yahoo when making an absolutely horrific config system. This brings back bad memories.
This may look cute but it is horrific when dealing with large configs and you have to reconstruct all the structure in your head. Also, when you have a format that nests using brackets, braces and parenthesis, you can get help from the editor. This format does not give you that. I'm not a huge fan of JSON (and the above mentioned format was invented because none of us were fans of XML at the time), but it turns out that both XML and JSON are actually easier to work with in practice than this format. Not least because there is ample tooling for JSON (and XML). The lesson I learnt: I may hate XML (or in this case JSON), but finding an alternative that is better is not easy.
I think the idea is not that this is for storage or editing, but just for querying - you should keep your data in JSON, but if you want to find where something is, do `catj foo.json | grep something` and it'll tell you all the paths in the document where you can find the string "something". The intent is not to open catj format in a text editor, or to use the output of catj for anything other than ad-hoc purposes.
This is really similar to the format that AWS uses to represent recursive structures (arrays, maps) as a single array of key-value pairs for their APIs. Your catj could potentially be used to create that if ever working with the raw API directly instead of a SDK.
Comments (120) 40 threads
Earlier commentsThis may look cute but it is horrific when dealing with large configs and you have to reconstruct all the structure in your head.
Also, when you have a format that nests using brackets, braces and parenthesis, you can get help from the editor. This format does not give you that.
I'm not a huge fan of JSON (and the above mentioned format was invented because none of us were fans of XML at the time), but it turns out that both XML and JSON are actually easier to work with in practice than this format. Not least because there is ample tooling for JSON (and XML).
The lesson I learnt: I may hate XML (or in this case JSON), but finding an alternative that is better is not easy.
jq can also do the same thing, with more flexibility. And it is possible to combine with bash alias to make it indistinguishable from catj
... or you know, you could put the jq script in an executable file and add a shebang like
or In my opinion, aliases should mostly be used to add default options only. Not really to insert whole scripts into them.That said, if you're stuck dealing with bad JSON like this with low signal to noise this is a decent way to redisplay it.
All comments shown.
Couldn't load more comments. Check your connection and try again.