News for hackers. Stuff that matters.
Re:Zq: An easier and faster alternative to jq by laurent123456 on Tuesday April 26, 2022 @12:28PM (#31169499)
I wonder if someone tried to use plain JS as a filtering language? It would be more verbose but it would be easy to remember. For example:

   [1,2,3] | js "out = 0; for (const n of this) out += n"
That would print "6". `out` would be a special variable you write to to print the result, and `this` would be the input.
Re:Zq: An easier and faster alternative to jq by rane on Tuesday April 26, 2022 @07:09PM (#31174301)
Not quite that, but ramda-cli[1] which I've created solves this problem, at least for me, by offering the familiar set of functions from Ramda, and you can create pipelines with those to do operations on your data.

[1]: https://github.com/raine/ramda-cli

Re:Zq: An easier and faster alternative to jq by mechanicalpulse on Tuesday April 26, 2022 @01:11PM (#31170159)
I've used trentm's json (formerly known as jsontool) package from npm as my default tool for command-line manipulation of JSON for many years now. It provides CLI arguments for passing JavaScript code for filtering and executing on input. I have resisted investing the time into becoming fluent in jq because I've found that many of the common use cases I have are readily handled by jsontool.

https://www.npmjs.com/package/json

Edit: added more information

Re:Zq: An easier and faster alternative to jq by Beltalowda on Tuesday April 26, 2022 @01:07PM (#31170093)
A few of the tools listed here seem to work like that, or roughly similar: https://ilya-sher.org/2018/04/10/list-of-json-tools-for-comm...

I didn't check any of them out though.

Re:Zq: An easier and faster alternative to jq by lgas on Tuesday April 26, 2022 @06:07PM (#31173762)
My hope was to one day add JS eval support to https://github.com/SuperpowersCorp/refactorio but as you can tell by the timestamps I haven't found any time to work on it in the last 4 years.
Re:Zq: An easier and faster alternative to jq by anitil on Tuesday April 26, 2022 @09:16PM (#31175136)
That's a really interesting suggestion, similar to how AWK uses $0, $1 etc.