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

Can jq do what gron does?



Technically no, because it offers no comparable way to interface to the line-based world of unix tools for interop.

Practically, most things you'd do with gron and grep, sed, awk, ... you could do using only jq as well. Jq comes with massive cognitive overhead though and has a bunch of very unpleasant gotchas (like silently corrupting numbers with abs > 2^53, although very recent jq graciously no longer does that iff you do no processing on the number).

I find jq pretty useful, but I have no love for it.


Actually, I think it might be possible to implement gron in jq (you can produce "plaintext" not just json, and the processing facilities jq offers might be powerful enough to escape everything appropriately, but it's not something I'm curious enough to find out to try).


> Can jq do what gron does?

It really depends on what you want to do, and thus what think gron does.

If all you want to do is search for properties with a given value then yes, jq does that very well.

Unlike gron, jq even allows users to output search results as valid json docs. Hell, jq allows users to transform entire JSON docs.

However, if all you want to do is expand the JSON path at each symbol then I don't know if jq supports that usecase. But then again, why would anyone want to do that?


The linked readme demonstrates gron outputting search results as json.




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

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

Search: