News for hackers. Stuff that matters.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by jeffbee on Monday September 14, 2020 @09:43AM (#24470013)
1) refuses to operate on stdin; requires a filename argument, which is so irritating.

2) doesn't accept values that jq accepts

  % time jq -r '[expression]' < parcels | wc       
      365    1454    7978
  jq -r  < parcels  1.39s user 0.00s system 99% cpu 1.390 total
  wc  0.00s user 0.00s system 0% cpu 1.390 total

  % time ~/.yarn/bin/q  '[expression]' parcels | wc
  q: internal error, uncaught exception:
     Yojson.Json_error("Line 56, bytes -1-32:\nJunk after end 
  of JSON value: '{\n  \"OBJECTID\": 155303,\n  \"BOOK\"'")
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by diggan on Monday September 14, 2020 @10:58AM (#24470914)
1 is easy to work around (handy tip incoming for any tools that _seem_ to not support stdin but actually do, as stdin is also available as a file in unix):

    echo '{"foo": "bar"}' | query-json ".foo" /dev/stdin
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by saagarjha on Monday September 14, 2020 @11:48AM (#24471541)
Tools that accept filenames often expect you give them a real file, as they’ll do things on it that may not be supported by the various “it’s a file descriptor pretending to be something on disk” solutions.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by diggan on Monday September 14, 2020 @12:00PM (#24471708)
Hm, do you have any examples handy? It's not that I don't believe you, it's just that in all the years I've been using this, it has always worked. Granted, I'm only using it for reading data, not for saving stuff to /dev/stdin, which would obviously fail.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by ebg13 on Monday September 14, 2020 @12:10PM (#24471829)
Anything that seeks, which you can't do on a pipe.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by waterhouse on Monday September 14, 2020 @05:50PM (#24475547)
atop parsing its logfiles.

  # Cuts off partway through:
  zcat atop.log.gz | atop -r /dev/stdin | less
  # Works fine:
  zcat atop.log.gz > atop && atop -r atop | less
That said, I agree with your experience that /dev/stdin usually works for programs that read a file straight in.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by aasasd on Monday September 14, 2020 @09:10PM (#24476901)
`file` on BSD/OSX has this notice for the option '-s':

> Normally, file only attempts to read and determine the type of argument files which stat(2) reports are ordinary files. This prevents problems, because reading special files may have peculiar consequences.

One example that comes to mind is /dev/urandom, which sucks randomy values out of the entropy pool (at least in Linux)—and the pool can be exhausted, or at least it could back in the day, not sure about now. Other possible cases are things in /proc (though unlikely), and particularly stuff like serial ports—where presumably reading could gobble data intended for some drivers or client software.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by ogdrhr on Monday September 14, 2020 @12:11PM (#24471849)
Not the best example here, but try to open a file descriptor in VSCode. I had a scenario where I wanted to diff a file on two different servers with a user-specified diff tool, and certain ones won't even operate in a read-only manner.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by centimeter on Monday September 14, 2020 @12:10PM (#24471832)
Seeking doesn’t work on stdin for example. Or mmapping, I imagine
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by viraptor on Monday September 14, 2020 @05:45PM (#24475496)
Untested, but I expect unzip will fail because it keeps metadata after the files, so needs to seek back. (Unless they detect the pipe and buffer everything instead)
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by boomlinde on Tuesday September 15, 2020 @04:28AM (#24479042)
fseek(3) etc, and using stat(2) to determine allocation sizes springs to mind as things you might want to do on a normal file that will not work as expected on a character device.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by chriswarbo on Monday September 14, 2020 @01:52PM (#24473023)
I try to avoid the dummy files /dev/stdin, /dev/stdout and /dev/stderr, since I've been bitten when they're not available, or when I hit permission denied errors.

Two examples I can remember off the top of my head:

- Nix build scripts

- OpenMoko

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by gpderetta on Monday September 14, 2020 @06:37PM (#24475932)
alternatively in bash:

   query-json ".foo" <(echo '{"foo": "bar"}')
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by davesnx on Monday September 14, 2020 @01:33PM (#24472771)
but indeed, it's a nice workaround!
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by davesnx on Monday September 14, 2020 @01:33PM (#24472769)
query-json --kind=inline would support reading from stdin, I didn't spend time on the Cmdliner enough!
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by f311a on Monday September 14, 2020 @09:51AM (#24470111)
That's super weird, I think most people use jq for bash pipelines.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by jeffbee on Monday September 14, 2020 @09:53AM (#24470129)
Yes, I don't understand how people end up with assertions that the filename is a require argument. At least we've got /dev/stdin or /proc/self/fd/0 as workarounds.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by caymanjim on Monday September 14, 2020 @10:37AM (#24470643)
Much Unix software today is written by people who really don't appreciate or understand Unix. It leads to things like Homebrew (early on, at least) completely taking over and breaking /usr/local; to command-line utilities using a single dash (-) precending both short and long option names (granted, --long-opts is a GNUism, but it's a well-established standard); commands that output color by default even when the output isn't a tty; etc.

It's not hard to fix things like this, but it exemplifies a lack of familiarity with the Unix command line. There are an enormous number of tools out there that only exist because people don't know how to chain together basic 1970s Unix text-processing tools in a pipeline.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by catblast on Monday September 14, 2020 @11:17AM (#24471165)
Anybody long enough to remember Unix from the beginning or even just the last 25 years... which is a tiny percentage of this site... should know that a unifying Unix or Unix "tradition" as noted in a follow-up comment is a pretty much a myth. The tradition is whatever system you grew up on and tribal biases you subscribe to and the only true Unix traditions are mostly trivialities like core shell syntax and a handful of commands, and a woefully underpowered API for modern purposes. And long option names are definitely not part of any tradition.

Myths like "everything is a file" or file descriptor is complete bollocks, mostly retconned recently with Linuxisms. Other than pipes, IPC on Unix systems did not involve files or file descriptors. The socket api dates to the early 80s and even it couldn't follow along with its weird ioctls. Why are things put in /usr/local anyway? Why is /usr even a thing? There's a history there, but these days I don't seem much of anything go into /usr/local on most Linux distributions.

It's also ironic to drag OS X into a discussion of Unix, because if there was one system to break with Unix tradition (for the best in some ways) -- no X11, launchd, a multifork FS, weird semantics to implement time machine, a completely non-POSIX low-level API, etc, that would be it.

All this shit has been reinvented multiple times, the user-mode API on Linux has had more churn than Windows -- which never subscribed to a tradition. There's no issue of lack of familiarity here, the original Unix system meant to run on a PDP-11 minicomputer only meets modern needs in an idealized fantasy-land. Meanwhile, worse is better has been chugging along for 50 years while people try to meet their needs.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by kbenson on Monday September 14, 2020 @01:27PM (#24472719)
> more churn than Windows -- which never subscribed to a tradition.

My understanding is that Windows has always had a very strong tradition of backwards compatibility. Even to the point of making prior bugs that vendors rely on still function the same way for them (i.e. detect if it's e.g. Photoshop requesting buggy API, serve them the buggy code path and everyone else the fixed one).

That's just as much a tradition as "we should implement this with file semantics because that's traditionally how our OS has exposed functionality".

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by saagarjha on Monday September 14, 2020 @11:52AM (#24471614)
> no X11

XQuartz if you want it

> completely non-POSIX low-level API

macOS has a POSIX layer.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by catblast on Monday September 14, 2020 @03:03PM (#24473821)
> XQuartz if you want it

There are X server implementations for Windows, Android, AmigaOS, Windows CE!!, etc... I don't think this is relevant.

> macOS has a POSIX layer. So do many systems, again including Windows in varying forms through the years. I think the salient issue is that BSD UNIX and "tradition" are conflicting. The point of the original CMU Mach project was to replace the BSD monolith kernel.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by derefr on Monday September 14, 2020 @11:31AM (#24471346)
Tangent: Homebrew itself doesn’t really choose to take over /usr/local; rather, it just accepts that there exists POSIX software that is way too hard for most machines to compile, and so must be distributed precompiled; and yet where that precompilation implies a burning-in of an installation prefix at build time, which therefore cannot be customized at install time. And so that software must be compiled to assume some installation prefix; and so Homebrew may as well also assume that installation prefix, so as to keep all the installed symlinks and their referents in the same place (i.e. on the same mountable volume.)

You have always been able to customize Homebrew to install at a custom prefix, e.g. ~/brew. It’s just that, when you do that, and then install one of the casks or bottles for “heavy” POSIX software like Calibre or TeX, that cask/bottle is going to pollute /usr/local with files anyway, but those files will be symlinks from /usr/local to the Homebrew cellar sitting in your home directory, which is ridiculous both in the multiuser usability sense, and in the traditional UNIX “what if a boot script you installed, relies on its daemon being available in /usr/local, which is symlinked to /home, but /home isn’t mounted yet, because it’s an NFS automount?” sense. (Which still applies/works in macOS, even if the Server.app interface for setting it up is gone!)

The real ridiculous thing, IMHO, is that Homebrew doesn’t install stuff into /usr, like a regular package manager. But due to macOS considering /usr part of its secure/immutable OS base-image, /usr is immutable when not in recovery mode.

I guess Homebrew could come up with its own cute little appellation — /usr/pkg or somesuch — but then you run into that other lovely little POSIXism where every application has its own way of calculating a PATH, such that you’d need to add that /usr/pkg directory to an unbounded number of little scripts here and there to make things truly work.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by vlovich123 on Monday September 14, 2020 @01:15PM (#24472595)
Or use `/opt` which is a POSIX-standard location. Every managed MacOSX laptop I've gotten from "Big Corp" has had `/usr/local` owned & managed by IT with permissions set to root meaning you're fighting Chef (or whatever your IT department prefers) if you use the default homebrew location.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by derefr on Monday September 14, 2020 @02:53PM (#24473703)
But again, you'd have that problem whether you used Homebrew or not, as soon as you tried to (even manually!) install the official macOS binary distribution of TeX, or XQuartz, or PostGIS, or...

Homebrew just acknowledges that these external third-party binary distributions (casks) are going to make a mess of your /usr/local — because that's the prefix they've all settled on burning in at compile-time — and so Homebrew tries to at least make that mess into a managed mess.

And, if some other system is already managing /usr/local, but isn't expecting the results of these programs unpacking into there, it's going to be very upset and confused — again, regardless of whether or not you use Homebrew. So it'd be better for those other systems to just... not do that.

/usr/local isn't supposed to be managed. It's supposed to be the install prefix that's controlled by the local machine admin, rather than by the domain admin. Homebrew just happens to be a tool for automating local-admin installs of stuff.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by vlovich123 on Monday September 14, 2020 @03:16PM (#24473960)
Where are domain admins supposed to put installations?
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by Pokepokalypse on Monday September 14, 2020 @01:20PM (#24472637)
The REAL ridiculous thing is that Homebrew was needed in the first place.

Mac OS X had some of the sexiest ways to install and uninstall application software that we'd ever seen in any other platform at that time.

But that Apple stubbornly refused to include a useful package management system, was one of the most horrible oversights in computing history.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by kbenson on Monday September 14, 2020 @01:17PM (#24472608)
> I guess Homebrew could come up with its own cute little appellation — /usr/pkg or somesuch —

/opt/homebrew would be a somewhat traditional place to put it.

> but then you run into that other lovely little POSIXism where every application has its own way of calculating a PATH, such that you’d need to add that /usr/pkg directory to an unbounded number of little scripts here and there to make things truly work.

What? You should be able to add it to the system PATH that's set for sessions and call it a day on a POSIX system. PATH is an environment variable and inherited. If MacOS is in the habit of overriding PATH on system scripts I have to imagine that's because they completely screwed it up at some point in the past. Generally, you just add it to your use session variables in whatever way your system supports (.profile, etc) if you want it for your user, or at a system level if you want it system wide (I could see maybe Apple making this hard).

The only times in over 20 years I've ever had to deal with PATH problems are when I ran stuff through cron, because it specifically clears the PATH. More recent systems just specify a default PATH in /etc/crontab for the traditional / and /usr bin and sbin dirs.

Maybe you're thinking of the shared library path loading? That should also be easily fixed.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by boomlinde on Tuesday September 15, 2020 @04:47AM (#24479152)
> and yet where that precompilation implies a burning-in of an installation prefix at build time

Not necessarily. Plenty of software uses relative paths that work regardless of prefix. Off the top of my head, Node.js is distributed in this way.

> you’d need to add that /usr/pkg directory to an unbounded number of little scripts here and there to make things truly work.

How so? Are there that many scripts that entirely replace the PATH environment variable? In Linux, I just include my system wide path additions in /etc/profile which will be set for every login. For things like cron jobs or service scripts, which don't inherit the environment of a login shell, you will need to source the profile or use absolute paths, but that's about the only caveat I can think of.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by ilikepi on Monday September 14, 2020 @12:24PM (#24471994)
> You have always been able to customize Homebrew to install at a custom prefix, e.g. ~/brew. It’s just that, when you do that...

...and then try to build something entirely sensible like Postgres, but hours of fiddling with different XCode versions and compiler flags still lead to a dead end of errors, you're stuck because you're running an unsupported configuration.

I still don't understand how the PG bottles for Mojave can be built.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by jeffbee on Monday September 14, 2020 @10:42AM (#24470709)
The `go` program uses -longopts and I think it would be hard to argue that Rob Pike lacks an appreciation of Unix traditions.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by bfrydl on Monday September 14, 2020 @11:18AM (#24471178)
I would argue that Go's design as a whole is characterized by an attitude of ignoring established ideas for no other reason than that they think they know better.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by thatjamesdude on Monday September 14, 2020 @11:45AM (#24471514)
Something being established is not a grand argument for it's usage. The reasons it got established are relavent, and if you feel the end result of said establishment is obtuse or inane, why would you use it?

That's not to say Go's decisions to toss some established practices are "wise" or "sagely", just that broad acceptance is not a criteria they seemed concerned with. Which is fine.

>they think they know better.

It's safe to say Rob Pike is not clueless or without experience in unix tooling. You should listen to some of his experiences and thoughts with designing Go [0]. I don't always agree with him, [but it's very baseless to suggest he makes decisions on the grounds that they were his, not they have merrit.]

Edit to clarify: [He makes decisions on merrit over authority]

[0]: https://changelog.com/gotime/100

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by bfrydl on Monday September 14, 2020 @12:26PM (#24472022)
Sure, there's nothing that says established practice is better. That is not, in my opinion, a good defense of Go which makes many baffling design decisions. Besides, an appeal to the authority of Rob Pike is surely not a valid defense if mine is not a valid criticism.

I'm (perhaps unfairly) uninterested in writing out all the details, but “they think they know better” is because I see Go as someone's attempt to update C to the modern world without considering the lessons of any of the languages developed in the meantime. And because of the weird dogmatic wars about generics, modules, and error handling.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by wahern on Monday September 14, 2020 @10:39PM (#24477381)
Rob Pike explained it thusly in a 2013 Google Groups reply:

> Rob 'Commander' Pike

> Apr 2, 2013, 6:50:36 AM

> to rog, John Jeffery, [email protected]

> As the author of the flag package, I can explain. It's loosely based on Google's flag package, although greatly simplified (and I mean greatly). I wanted a single, straightforward syntax for flags, nothing more, nothing less.

> -rob

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by mcguire on Monday September 14, 2020 @02:18PM (#24473319)
Rob Pike lacks an appreciation of GNU traditions.

I'm actually surprised by this; I would have expected Pike to go with single-letter options only.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by caymanjim on Monday September 14, 2020 @11:35AM (#24471384)
This is a fair point, although ironically it's probably because Pike predates GNU and still has a problem with all the conventions those young upstarts eschewed. Conventions change, usually for the better. I think this is one the Go team got wrong, regardless of the reason.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by 1vuio0pswjnm7 on Monday September 14, 2020 @06:12PM (#24475732)
"There are an enormous number of tools out there that only exist because people don't know how to chain together basic 1970s Unix text-processing tools in a pipeline."

Arguably that is why the original implementation of Perl was written. If I remember the story correctly, we can never know for sure whether, e.g., AWK would have sufficed, because the particular the job the author wrote Perl for as a contractor was confidential.

Are people using jq most concerned about speed, or are they more concerned about syntax.

JSON suffers a problem from which line-oriented untilities generally have immunity: a large enough and deeply nested JSON structure will choke or crash a program that tries to read all the data into memory at once, or even in large chunks. The process is resource-constrained as the size of the data increases. There are no limits placed on the size or depth of JSON files.

I use sed and tr for most simple JSON files. It is possible to overlfow the sed buffer but it rarely ever happens. sed is found everywhere and it's resource-friendly. Others might choose a program for speed or syntax but the issue of reliability is even more important to me. jq alone is not a reliable solution for any and all JSON. It can be overkill for simple json and resource-constrained for large, complex JSON.

https://stackoverflow.com/questions/59806699/json-to-csv-usi...

netstrings (https://cr.yp.to/proto/netstrings.txt) do not suffer from the same problem as JSON.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by mschuster91 on Monday September 14, 2020 @01:52PM (#24473025)
> It leads to things like Homebrew (early on, at least) completely taking over and breaking /usr/local

Fully agree with you, but oh well, most if not everything is available on Macports anyway.

> There are an enormous number of tools out there that only exist because people don't know how to chain together basic 1970s Unix text-processing tools in a pipeline.

Speed. A specialized tool you need often beats manually wrangling the dozen or so Unix tools you need to replace it, plus many Good Options are only available on the GNU/Linux coreutils and don't work on Macs (sed -i, my most common annoyance) or busybox.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by monadic2 on Monday September 14, 2020 @01:06PM (#24472496)
People often complain about homebrew's use of usr local without articulating what is lost.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by benibela on Monday September 14, 2020 @09:59AM (#24470209)
files might be faster, because you can mmap them?
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by f311a on Monday September 14, 2020 @10:09AM (#24470326)
Most people work on compressed JSON lines files. Sometimes they are stored on s3. Files do not give flexibility.

When using jq, I can do a lot of things:

    aws s3 cp s3://bucket/file.json.gz - | zcat | head | jq .field | sort
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by jerf on Monday September 14, 2020 @10:23AM (#24470492)
Another common thing you can do is accept a generic stream as input, but have some code that penetrates the abstraction a bit to see what kind of stream it is, and if it is a file or something, do something special with it to go even faster. This way, you start with something maximally useful up front, and easy to use, but you can optimize things based on details as you go.

That's how Go's static file web server works. It serves streams, but if you happen to io.Copy to that stream with something that is also an ∗os.File on Linux, it can use the sendfile call in the kernel instead. (A downside of making it so transparent is that if you wrap that stream with something you may not realize that you've wrecked the optimization because it no longer unwraps to an ∗os.File but whatever your wrapper is, but, well, nothing's perfect.)

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by Spivak on Monday September 14, 2020 @10:24AM (#24470501)
Which is sorta-kinda the same thing as

  jq .field <(aws s3 cp s3://bucket/file.json.gz - | zcat | head) | sort
which is more annoying to type but works.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by dullgiulio on Monday September 14, 2020 @12:37PM (#24472149)
Redirection is not a parameter, meaning that would still not work with this Q tool.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by jraph on Monday September 14, 2020 @01:07PM (#24472515)
This is not a simple redirection. cmd <(subcmd) is a bashism that redirects the output of command subcmd to something that looks like a regular file to command cmd. Command cmd receive a path at the place the <(subcmd) syntax is used. Different from cmd < f, which redirects the contents of file f to cmd's input.

So, this should work :-)

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by jeffbee on Monday September 14, 2020 @01:11PM (#24472558)
Works in other shells, not just bash

  % cat /proc/self/cmdline <(echo $SHELL) | tr '\0' ' '
  cat /proc/self/cmdline /proc/self/fd/11 /bin/zsh
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by jraph on Monday September 14, 2020 @01:14PM (#24472585)
Yep! Zsh supports a lot of bashisms :-)

It won't work in dash though, and you should not use this in a shell that targets POSIX.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by ashtonkem on Monday September 14, 2020 @10:39AM (#24470669)
My most common jq usage is to copy and paste some json into quotes to make it easier to read. My second most common action is to chain curl and jq together. A replacement for jq that doesn’t use stdin is literally useless to me.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by yawaramin on Monday September 14, 2020 @01:03PM (#24472467)
I think at least two people in the thread pointed out that you can use /dev/stdin as a file.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by ashtonkem on Monday September 14, 2020 @01:42PM (#24472882)
That’s a cumbersome extra step for unclear benefit.

Yes, q is supposedly faster than jq. But it is exceedingly rare for me to ever have any performance problems with jq, especially since it’s essentially a one off utility I use occasionally, not as part of the hot loop of any workflow where performance matters.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by yawaramin on Monday September 14, 2020 @10:50PM (#24477445)
In that case I suppose you wouldn't use it.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by monadic2 on Monday September 14, 2020 @01:09PM (#24472543)
It's more than a little strange that isn't default behavior out of the box without specifying input. How do the authors think jq is used?
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by davesnx on Saturday September 19, 2020 @07:42AM (#24526753)
I trend to use jq with a file all the time, I prefer to curl first and later operate on top. /slug
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by yawaramin on Monday September 14, 2020 @10:50PM (#24477437)
I'm pretty sure the author has also replied elsewhere saying he will add it since it was brought up as a concern.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by kilroy123 on Monday September 14, 2020 @10:51AM (#24470830)
Probably true but I use it regularly in the automation app huginn.

https://github.com/huginn/huginn

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by davesnx on Monday September 14, 2020 @10:41AM (#24470688)
Nothing that can be fixed later?
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by freedomben on Monday September 14, 2020 @10:55AM (#24470880)
Thanks for this. I've been planning a similar work for years and haven't gotten off my ass (too many other projects lol).

I definitely agree that reading from stdin is critical if I'll be able to use it. Don't take the criticism too hard though (especially the "author doesn't appreciate unix" stuff. Sometimes we can be such assholes to each other).

Nice work!

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by davesnx on Monday September 14, 2020 @11:56AM (#24471662)
I'm happy with the critics.

Judging is free and I didn't consider stdin as something to spend time on yet. Will do, now that some people raise it.

Thanks :D

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by jeffbee on Monday September 14, 2020 @10:44AM (#24470730)
Probably. You tell us :=)

The incompatibility is apparently due to the fact that jq is happy with a concatenation of JSON objects and q is not. For example {'foo':1}{'foo':2} as opposed to [{'foo':1},{'foo':2}]

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by davesnx on Monday September 14, 2020 @10:53AM (#24470847)
Sure, it's a missing feature "," creates 2 spins of the filter.

I certantly didn't use it, but I see where it's useful, will implement it soon.

Re:Q: A faster re-implementaiton of jq written in Reason Nat... by pwm on Monday September 14, 2020 @11:37AM (#24471415)
To be fair that is a JSON parse error.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by jeffbee on Monday September 14, 2020 @11:40AM (#24471438)
Yes, but the inputs to jq are not JSON, they are "a sequence of whitespace-separated JSON values which are passed through the provided filter one at a time" which is the relevant thing if you are going to try to replace jq.
Re:Q: A faster re-implementaiton of jq written in Reason Nat... by davesnx on Saturday September 19, 2020 @07:43AM (#24526761)
Yep, kind of.

The comma operations means that the "filters" are duplicated, so instead of one json state you would pass two if there's one coma; and ofcourse any number of commas are allowed.