Live data from Hacker News

Show HN: Catj – A new way to display JSON files

github.com

21–30 of 127 posts

Re: Show HN: Catj – A new way to display JSON files

#24
post #7

this is not merely a display, it is really a sanitation of the brain-damaged json syntax.

Your opinion is bad.

json will be mocked in a few years by the same people that today mock xml. In the end, unix always survives.

Re: Show HN: Catj – A new way to display JSON files

#25
post #5

Have you seen gron[0]? It's similar: flattens JSON documents to make them easily greppable. But it also can revert (ie, ungron) so you can pipe json to gron, grep -v to remove some data, then ungron to get it back to json. [0] https://github.com/tomnomnom/gron

I haven't seen that one, but it looks very similar to the one I use: https://github.com/micha/json-table

Re: Show HN: Catj – A new way to display JSON files

#26

Earlier quoted context omitted.

Your opinion is bad.

json will be mocked in a few years by the same people that today mock xml. In the end, unix always survives.

"unix" isn't a file format, nor is it in competition with either XML or JSON, so claiming it will "survive" either is a meaningless boast.

Re: Show HN: Catj – A new way to display JSON files

#29
post #20

I was curious if this could be doable with jq, and apparently it is: jq -j ' [ [ paths(scalars) | map( if type == "number" then "[" + tostring + "]" else "." + . end ) | join("") ], [ .. | select(scalars) | @json ] ] | transpose | map(join(" = ") + "\n") | join("") ' EDIT: Got the string quoting and escaping. EDIT 2: For those who want to save this script, you can put just the jq code in an executable file with the s…

I was expecting some mention of jq for this post, and you did not disappoint. Thank you for the script -- it works great and I'm adding it to my collection.

Re: Show HN: Catj – A new way to display JSON files

#30
I wrote a similar tool:

https://github.com/twpayne/flatjson

The flat format is great for diffs:

  --- testdata/a.json
  +++ testdata/b.json
  @@ -1,5 +1,6 @@
   root = {};
   root.menu = {};
  +root.menu.disabled = true;
   root.menu.id = "file";
   root.menu.popup = {};
   root.menu.popup.menuitem = [];
  @@ -9,8 +10,5 @@
   root.menu.popup.menuitem[1] = {};
   root.menu.popup.menuitem[1].onclick = "OpenDoc()";
   root.menu.popup.menuitem[1].value = "Open";
  -root.menu.popup.menuitem[2] = {};
  -root.menu.popup.menuitem[2].onclick = "CloseDoc()";
  -root.menu.popup.menuitem[2].value = "Close";
  -root.menu.value = "File";
  +root.menu.value = "File menu";
Post reply on HN