Show HN: Catj – A new way to display JSON files
51–60 of 127 posts
Re: Show HN: Catj – A new way to display JSON files
#52I 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…
Re: Show HN: Catj – A new way to display JSON files
#53Have 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?
Re: Show HN: Catj – A new way to display JSON files
#54Earlier 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.
Re: Show HN: Catj – A new way to display JSON files
#55Re: Show HN: Catj – A new way to display JSON files
#56Have 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
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
#57Have 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!
Re: Show HN: Catj – A new way to display JSON files
#58Re: Show HN: Catj – A new way to display JSON files
#59 $ augtool -r . -L --transform 'JSON.lns incl /catj-eg.json'
[0] $ ls .../share/augeas/lenses/dist/|wc
221 221 2867Re: Show HN: Catj – A new way to display JSON files
#60I 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
Maybe not, but I'm pretty sure every system supports a single arg. And very few (none?) support more.