Re:Zq: An easier and faster alternative to jq
by MarkMarine on Tuesday April 26, 2022 @10:19PM
(#31175534)
counter point: I reach for jq probably twice a year. It's a slog every time, but way way less work than diving into the terse syntax and understanding the inner workings of jq. A good abstraction is the border of my understanding, a leaky abstraction means I have to have mastery of the internals to be successful. jq is a leaky abstraction.
Re:Zq: An easier and faster alternative to jq
by hyperpallium2 on Tuesday April 26, 2022 @09:32PM
(#31175225)
can also use name instead of name:.name
I think jq is very elegant - genius even - but whenever I use it, I have to look up the docs for syntax. But I guess that's true for any infrequently used tool.
Re:Zq: An easier and faster alternative to jq
by chris37879 on Tuesday April 26, 2022 @10:03PM
(#31175425)
This exactly. I think JQ's problem in this regard is further compounded because its query language just doesn't feel like anything else most people have used, I've certainly never come across anything quite like it, anyway.
People with the time and inclination to slow down and think a little more about how the tools work will produce cleaner solutions.
In your example to convert
to All you need is this jq filter To me this is much better than the proposed zq or jq solution you're using as a basis for comparison. You could almost use the shorter if the name in the output didn't change.These filters takes advantage of how jq's [] operator converts a single result into separate results. For people new to jq this behavior is often confusing unless they've seen things like Cartesian products.
.[] - https://stedolan.github.io/jq/manual/#Array/ObjectValueItera...