Hacker News new | past | comments | ask | show | jobs | submit login

This post inspired me to add a similar post to my own blog. Why?

Today I needed to parse some JSON at the command line and do some basic search and replaces and convert it all to CSV. The API call was easy enough with wget, and I was going to use JQ to parse the JSON. But after fiddling with it for 20 minutes and not having much luck, I resorted to my favorites:

Awk, sed, grep, cut. Save API call output to a couple of temp files, parse it with the aforementioned Unix staples in a for loop, And unless time than it would have taken me to properly learn JQ, I had the output and was able to ship it off to my customer.

Sometimes the best tool for the job is the tool you know, love, and trust.




Try `gron`. Great for taking JSON and converting it into something that can be grep'ed, and then if you need JSON out on the other end, you can then use `gron -u` to reverse the operation.

Saved my sanity more times than I can count, and allows me to avoid the Cthonic black magic known as `jq`.


I'll check it out- but the problem is portability. The script I wrote may need to run on machines that don't have anything but awk sed grep cut etc...

That being said, I'll check it out on my local machine :)


Amazing tool. Thank you.


Cheers, mate!

> Today I needed to parse some JSON

You had some JSON blob, and you actually needed to glean something from it quickly and painlessly. To paraphrase Zawinski et al., you then found you had two problems.

In this age of big data, the debate between parsable and human-readable state has been resolved. JSON is an anti-pattern that requires supplementary tooling to make any sense of it, nevermind naive readability.


chatgpt is really good for creating the correct jq queries.


It's funny that you mention that! I was discussing it with a co-worker to see if they were any better with JQ than I was. They weren't. But then I realized I probably could have used chat GPT to do it. It really is a great tool for that kind of thing.


Indeed, the greatest triumph of ChatGPT is to reduce the need to discuss with co-workers! :D


jq i find unintuitive. I prefer to use node repl to so this kind of stuff.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: