Live data from Hacker News

Zq: An easier and faster alternative to jq

brimdata.io

31–40 of 237 posts

Re: Zq: An easier and faster alternative to jq

#31

Pardon my ignorance, but would I spend time learning something like jq or zq when it only takes me a couple of minutes to develop a script using some high-level language? I've had to process complex JSON files in the past, and a simple Python script gets the job done, and the syntax is much more familiar and easier to memorize. Is there a use case I'm missing?

The same thing could be said for grep, or really any other utility that can have its functionality reproduced in a programing language.

Re: Zq: An easier and faster alternative to jq

#32

The name of its corporate progenitor may leave a bad taste in some mouths, but I highly recommend PowerShell for this sort of thing. It's cross platform, MIT licensed, and comes with excellent JSON parsing and querying capabilities. Reading, parsing, and querying JSON to return all red cars: Get-Content cars.json | ConvertFrom-Json | ? { $_.color -eq 'red' } The beauty of this is that the query syntax applies not jus…

I want to learn powershell, but I have an internal ick bias because I've been using bash for so many years. The tab behavior is the exact opposite of what I expect and it short circuits my brain every single time I press it. Having structured data in the pipes seems very useful and powerful though so I should probably just bite the bullet.

Re: Zq: An easier and faster alternative to jq

#33
post #18

Earlier quoted context omitted.

PowerShell "sends basic telemetry data to Microsoft [...] about the host running PowerShell, and information about how PowerShell is used" [1]. And since it relies on .NET, that also requires its own separate opt-out for its telemetry. There might be other components, now or in the future, that also send data to Microsoft by default and would have to be separately discovered and disabled. [1] https://docs.microsoft.c…

To me a telemetry opt-out is a small price to pay for what PowerShell brings to the table, but to each their own. > There might be other components, now or in the future, that also send data to Microsoft Of course. Do your due diligence on whatever you install. No tool should be exempt from that.

> Do your due diligence on whatever you install. No tool should be exempt from that.

That's a ridiculous take. 99% of users don't understand what all that technobabble in a typical EULA means, they will just go for the option they are nudged to (which is why first the courts and now enforcement agencies are stepping up their game against that practice [1]).

The way that the GDPR expects stuff to be handled is by getting explicit user consent, the consent must be a reasonably free choice (i.e. deals like "give me your personal data and the app is free, otherwise pay" are banned), and there must not be any exchange of GDPR-protected data without that consent unless technically required to perform the service the user demands. Clearly, a telemetry opt-out is completely against the spirit of the GDPR and I seriously hope for Microsoft to get flattened by the courts for the bullshit they have been pulling for way too long now.

What I would actually expect of Microsoft is to follow the Apple way: have one single central place, ideally at setup and later in the System Preferences, where tracking, analytics and other optional crap can be disabled system-wide.

[1] https://www.hiddemann.de/allgemein/lg-rostock-bejaht-unterla...

Re: Zq: An easier and faster alternative to jq

#35

Pardon my ignorance, but would I spend time learning something like jq or zq when it only takes me a couple of minutes to develop a script using some high-level language? I've had to process complex JSON files in the past, and a simple Python script gets the job done, and the syntax is much more familiar and easier to memorize. Is there a use case I'm missing?

I am also on the same side of the discussion, but I'm a programmer by trade. Most of the cases I've seen non trivial jq uses is by people doing command line or shell script magic. In this context I guess it's easier to write the jq expression language than to whip up a fully fledged Python/Ruby/Perl script without having to debug pretty basic stuff once you know the syntax. Pretty much like awk.

I'm a programmer by trade. I use jq. :)

Re: Zq: An easier and faster alternative to jq

#36

Pardon my ignorance, but would I spend time learning something like jq or zq when it only takes me a couple of minutes to develop a script using some high-level language? I've had to process complex JSON files in the past, and a simple Python script gets the job done, and the syntax is much more familiar and easier to memorize. Is there a use case I'm missing?

jq is great for shell scripts. Say your script hits an API that returns JSON, and you want to retrieve a single field. This can be difficult to do correctly with grep or other text matching tools, but is trivial with jq. You just pipe it in like "curl XYZ | jq '.path.to.your.data'"

I imagine this is how it's used 90% of the time, but can do lots more advanced stuff as described in the article.

Re: Zq: An easier and faster alternative to jq

#37

Pardon my ignorance, but would I spend time learning something like jq or zq when it only takes me a couple of minutes to develop a script using some high-level language? I've had to process complex JSON files in the past, and a simple Python script gets the job done, and the syntax is much more familiar and easier to memorize. Is there a use case I'm missing?

There is certainly a learning curve with jq that can put people off. The attraction is that the end result is a very small amount of code that does only one thing: parse a JSON file, rather than invoking an external script that might send many HTTP requests or launch a missile.

As the complexity of the input JSON grows or the complexity of your processing, it does makes sense to leave jq behind for a higher level language.

Re: Zq: An easier and faster alternative to jq

#38
post #32

The name of its corporate progenitor may leave a bad taste in some mouths, but I highly recommend PowerShell for this sort of thing. It's cross platform, MIT licensed, and comes with excellent JSON parsing and querying capabilities. Reading, parsing, and querying JSON to return all red cars: Get-Content cars.json | ConvertFrom-Json | ? { $_.color -eq 'red' } The beauty of this is that the query syntax applies not jus…

I want to learn powershell, but I have an internal ick bias because I've been using bash for so many years. The tab behavior is the exact opposite of what I expect and it short circuits my brain every single time I press it. Having structured data in the pipes seems very useful and powerful though so I should probably just bite the bullet.

Tab behavior is configurable. I have mine set to menu expansion.

    Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete

Re: Zq: An easier and faster alternative to jq

#39

jq is incredibly powerful and I'm using it more and more. Even better, there is a whole ecosystem of tools that are similar or work in conjunction with jq: * jq (a great JSON-wrangling tool) * jc (convert various tools’ output into JSON) * jo (create JSON objects) * yq (like jq, but for YAML) * fq (like jq, but for binary) * htmlq (like jq, but for HTML) List shamelessly stolen from Julia Evans[1]. For live links see…

Also highly recommended is gron [0], to make json easily searchable

[0] https://github.com/TomNomNom/gron

Re: Zq: An easier and faster alternative to jq

#40

Earlier quoted context omitted.

To me a telemetry opt-out is a small price to pay for what PowerShell brings to the table, but to each their own. > There might be other components, now or in the future, that also send data to Microsoft Of course. Do your due diligence on whatever you install. No tool should be exempt from that.

> Do your due diligence on whatever you install. No tool should be exempt from that. That's a ridiculous take. 99% of users don't understand what all that technobabble in a typical EULA means, they will just go for the option they are nudged to (which is why first the courts and now enforcement agencies are stepping up their game against that practice [1]). The way that the GDPR expects stuff to be handled is by gett…

> What I would actually expect of Microsoft is to follow the Apple way: have one single central place, ideally at setup and later in the System Preferences, where tracking, analytics and other optional crap can be disabled system-wide.

This is still GDPR non-compliant, you should have a central place to _opt-in_ tracking, analytics and other optional crap if you so desire.

Post reply on HN