On Mon, 13 Jan 2020, Dan Cross wrote:
[Resending as this got squashed a few days ago. Jon, sorry for the
duplicate. Again.]
On Sun, Jan 12, 2020 at 4:38 PM Jon Steinhart <jon(a)fourwinds.com> wrote:
<snip>
Many
people have claimed, incorrectly in my opinion, that this model
fails in the modern era because it only works on text data. They
change the subject when I point out that ImageMagick works on binary
data. And, there are now stream processing utilities for JSON data
and such that show that the UNIX model still works IF you understand
it and know how to use it.
Certainly. I think you hit the nail on the head with the proviso
that one must _understand_ the Unix model and how to use it. If one
does so, it's very powerful indeed, and it really is applicable more
often than not. But it is not a panacea (not that anyone suggested it
is). As an example, how do I apply an unmodified `grep` to arbitrary
JSON data (which may span more than one line)? Perhaps there is a way
(I can imagine a 'record2line' program that consumes a single JSON
object and emits it as a syntactically valid one-liner...) but I can
also imagine all sorts of ways that might go wrong.
And here, understanding the model is important, namely, grep is the
wrong tool for searching/parsing JSON output. Dealing with JSON from the
shell, you should use jq. I've been dragged kicking and screaming into
dealing with JSON, and about all I can say about it is, I like it about
this >< much more than XML. :)
--
Michael Parson
Pflugerville, TX
KF5LGQ
Slight disagreement here. I would say that grep is *a* a tool for JSON and
that jq is *a better* one.