Hacker News new | ask | show | jobs
by Yanael 933 days ago
How have you been using jq? It is more adhoc for exploring JSON files during development/data analysis or in programs that run in production?
4 comments

Quite a lot! i use it to explode both JSON and tex (parse using jq functions). I also use it for exploring ane debug binary formats (https://github.com/wader/fq). Now a days i also use it for some adhoc programming and a calculator.
Oh sounds a very neat way to explore binary!
If you spend lots of time with certain binary formats then i can recommend adding a decoder, happy to help with it also!
Yeah, I've always liked the idea of jq but personally I find it easier to open a REPL in the language I'm most familiar with (which happens to be JS, which does make a difference) and just paste in the JSON and work with it there

It may be more verbose, but I never have to google anything, which makes a bigger difference in my experience

https://github.com/wader/fq has a REPL and can read JSON. Tip is to use "paste | from_json | repl" in a REPl to paste JSON into a sub-REPL, you can also use `<text here>` with fq which is a raw string literal
The important part wasn't having a REPL, it was using a language I already know off the top of my head
Yes. So much easier to reuse other common helper functions. Once you’ve finished exploration you can just copy the code into production instead of translating.
My most common usage is pretty-printing the output of curl, or getting a list of things from endpoint service/A and then calling service/endpoint B/<entry> to do things for each entry in the list.
I use it as a "JSON library for bash". :-)

Not really in "production", but I have a lot of small-ish shell scripts all over the place, mostly in ~/bin, and some in CI (GitHub Actions) as well.