[HN Gopher] Make JSON Greppable ___________________________________________________________________ Make JSON Greppable Author : mooreds Score : 32 points Date : 2023-12-03 21:45 UTC (1 hours ago) (HTM) web link (github.com) (TXT) w3m dump (github.com) | g105b wrote: | Looks like an interesting tool. I use jq for any JSON related | task, but it can often be finicky and complex when I just need to | get at a value or search for something. | | Looks like gron would be a nice addition to my workflow with JSON | tasks. | blcknight wrote: | This is brilliant, I can't wait to have a json problem to try it | out. | rauljara wrote: | Hmmm... at first glance, this feels like I'd use it for the same | sorts of things I'd use jq for, only easier to use but also way | less powerful. Jq does have a little bit of a learning curve | necessary to get good use out of it, so I could see this being a | nice quick tool for people who don't want to make that | investment. Having already learned jq, I'm not sure why I would | reach for gron, but maybe I'm missing something. | derwildemomo wrote: | Great idea, definitely makes sense when you have that kind of | problem. | | Also the username of the author made me chuckle, bonus points for | that. | omeid2 wrote: | As someone who has been using jq for years, my first instinct was | why not jq? and while it answers it in the README as well, it is | not very clear until you compare the output to jq. | $ gron | "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" | | fgrep "commit.author" json[0].commit.author = {}; | json[0].commit.author.date = "2016-07-02T10:51:21Z"; | json[0].commit.author.email = "mail@tomnomnom.com"; | json[0].commit.author.name = "Tom Hudson"; | | And with jq: $ curl | "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" | | jq ".[].commit.author" { "name": "Tom | Hudson", "email": "mail@tomnomnom.com", | "date": "2022-04-13T14:23:37Z" } | | The jq version isn't greppable, as you can't do `| grep | '.author.email'` for example. | slt2021 wrote: | This is awesome! | | I am going to try to use it to make surgical edits to the | terraform state file, in rare cases when I have to. | | Some terraform providers would rather delete and recreate | resource, while a simple edit would do the trick for me | salted-fry wrote: | I use gron a lot, because I can never remember how to use jq to | do anything fancy but can usually make awk work. (I may be | unusual in that department, in that I actually like awk) | | One warning to note is that gron _burns_ RAM. I 've killed 32GB | servers working with 15MB JSON files. (I think gron -u is even | worse, but my memory is a bit fuzzy here). | | https://github.com/adamritter/fastgron has been pretty good to me | in terms of performance, I think both in speed and RAM usage. | Eumenes wrote: | can see this being useful for pentesting, jq is fine but always | have to look at documentation and relearn it every few | weeks/months ___________________________________________________________________ (page generated 2023-12-03 23:00 UTC)