News for hackers. Stuff that matters.
Re:Show HN: Catj – A new way to display JSON files by inferiorhuman on Friday June 21, 2019 @05:43PM (#20246536)
What does grep + gron give you over jq?
Re:Show HN: Catj – A new way to display JSON files by pfranz on Friday June 21, 2019 @06:08PM (#20246670)
jq seems very powerful. I don't deal with json all that often and my most common use case (by far) is `jq '.' -C` and it took a few tries for me to remember that syntax.

The idea of flattening, grepping, then reverting sounds very appealing and sounds like a better fit for me.

Re:Show HN: Catj – A new way to display JSON files by jolmg on Friday June 21, 2019 @07:24PM (#20247064)
> `jq '.' -C` and it took a few tries for me to remember that syntax.

I don't think you really need neither `.` nor `-C`. Just `jq` seems to do the same colored output of the input by default.

Re:Show HN: Catj – A new way to display JSON files by pfranz on Saturday June 22, 2019 @02:41AM (#20248347)
It does look like neither are needed if you pipe a file in jq, but `jq . file.json` requires the `.` and if you're pipeing into a pager, like less, you need both `.` and `-C` to get colored output (that was the case with the alias I had pulled up). I am using 1.5 and haven't looked to see if 1.6 changes this.
Re:Show HN: Catj – A new way to display JSON files by jolmg on Saturday June 22, 2019 @02:51AM (#20248368)
I see. I doubt that behavior has changed, then.

`-C` would be required when piping because most of the time (with the exception of piping into less) when stdout is not a terminal, it doesn't make sense to include terminal color escape sequences. You'd end up with those codes in your files, and grep would be looking at them for matches, for example.

`.` would be required when passing the file as an argument instead of stdin, because jq interprets the first argument as jq-code. If you don't include `.` it would interpret the filename as jq-code.

Re:Show HN: Catj – A new way to display JSON files by pfranz on Sunday June 23, 2019 @01:01AM (#20253399)
`.` is still needed if I'm pipeing in json--but only when I'm piping out. Otherwise help goes to stderr and nothing goes to stdout.

I do honestly think jq is a cool and powerful tool. I also appreciate little things like auto-color when appropriate--git also does this. Git also uses your pager, which might trivialize my personal use case.

Re:Show HN: Catj – A new way to display JSON files by dirkt on Sunday June 23, 2019 @02:39AM (#20253639)
Wrong question: It's not a competition.

There are cases when you have some complicated json and just want to search for stuff. Then you use grep + gron.

There are cases when you want a complete json processing tool. Then you use jq.

You can probably simulate each approach with the other approach, but the code needed to this is just too tedious to write. So you use whatever tool fits your use case.

Re:Show HN: Catj – A new way to display JSON files by nerdponx on Sunday June 23, 2019 @03:36PM (#20258172)
No, but you still have to make a decision about which tool to use. So it's helpful to have a sense of the use cases for each.
Re:Show HN: Catj – A new way to display JSON files by ElegantGiraffe on Saturday June 22, 2019 @02:55AM (#20248378)
I find it useful when I don't know what the json schema is. Then you can just do a quick gron + grep and find where the interesting parts of a large json document are.
Re:Show HN: Catj – A new way to display JSON files by webo on Friday June 21, 2019 @05:59PM (#20246622)
as far as i can tell, jq doesn't do flattening .
Re:Show HN: Catj – A new way to display JSON files by pstuart on Friday June 21, 2019 @06:47PM (#20246878)
Not built in, but @jolmg posted a script here which does the needful.
Re:Show HN: Catj – A new way to display JSON files by lucb1e on Friday June 21, 2019 @06:05PM (#20246647)
Maybe GP meant that jq can do selection as well, i.e. that grepping is redundant after jq. But jq is much more complicated to learn and grep works on all inputs (not just json), so it makes a lot more sense to learn and use grep properly.
Re:Show HN: Catj – A new way to display JSON files by ori_b on Friday June 21, 2019 @11:08PM (#20247777)
Simplicity.