Live data from Hacker News

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

github.com

51–60 of 127 posts

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

#52
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…

[deleted]

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

#53
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

What does grep + gron give you over jq?

Simplicity.

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

#54
post #46
post #41

Earlier quoted context omitted.

Holy moly, Your jq skills are savage.

Thanks, but I haven't really done much in jq before. Doing the above script involved looking a lot through the manual and experimenting. This exercise was a learning experience for me. I was only able to do this because the manpage is well written.

Huh, that's the spirit.

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

#55
post #45
post #6

Earlier quoted context omitted.

Actively developed and written in Go. The project linked to is from 2014 with last update in 2015.and it is on NPM... What is left to say? Thank you!

Used to be written in php right?

This "joke" is so incredibly old.

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

#56
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

That's actually a nice lifehack. Much simplier than jq. Unfortunately, would be harder to make all kinds of logical conditions for which jq allows (even if not that intuitively).

It still feels like there must be something in between, some way to make queries with json more naturally, than with jq, yet with enough power.

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

#57
post #6
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

Actively developed and written in Go. The project linked to is from 2014 with last update in 2015.and it is on NPM... What is left to say? Thank you!

What's wrong with it not being updated in 5 years? It's a simple script. It's probably stable and doesn't need to be "actively developed".

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

#60
post #49
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…

IIRC in a hashbang isn't posix compatible

Args in a hashbang?

Maybe not, but I'm pretty sure every system supports a single arg. And very few (none?) support more.

Post reply on HN