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…
Show HN: Catj – A new way to display JSON files
41–50 of 127 posts
Re: Show HN: Catj – A new way to display JSON files
#42Re: Show HN: Catj – A new way to display JSON files
#43For exploring large files I released a program called "JSONSmash" that runs a shell which lets you browse the data as if it was a filesystem. https://blog.tedivm.com/open-source/2017/05/introducing-json...
As you've already implemented most relevant commands (cd, ls, cat), it would probably be easy to make a FUSE version using fs-fuse / fuse-bindings
Re: Show HN: Catj – A new way to display JSON files
#44Re: Show HN: Catj – A new way to display JSON files
#45Have 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
#46I 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…
Holy moly, Your jq skills are savage.
Re: Show HN: Catj – A new way to display JSON files
#47Re: Show HN: Catj – A new way to display JSON files
#48Earlier quoted context omitted.
Would probably be shorter if you used `tostream`
You're right. Good tip: jq -r ' tostream | select(length > 1) | ( .[0] | map( if type == "number" then "[" + tostring + "]" else "." + . end ) | join("") ) + " = " + (.[1] | @json) ' EDIT: For those who want to save this script, you can put just the jq code in an executable file with the shebang: #!/usr/bin/jq -rf
jq -r '
( tostream
| select(length > 1)
| (
.[0] | map(
if type == "number"
then "[" + tostring + "]"
else "." + .
end
) | join("")
)
+ " = "
+ (.[1] | @json)
+ " |"
),
"."
'Re: Show HN: Catj – A new way to display JSON files
#49I 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
#50https://sqlite.org/json1.html#jtree
SELECT big.rowid, fullkey, value
FROM big, json_tree(big.json)
WHERE json_tree.type NOT IN ('object','array');