Re: Structured (ie: json) output for query commands?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 01, 2021 at 09:18:01PM +0000, brian m. carlson wrote:

> > I don't love the invalid-utf8-in-json thing in general. But I think it
> > may be the least-bad solution. I seem to recall that YAML has its own
> > complexities, and losing human-readability (even to base64) is a pretty
> > big downside. And the tooling for working with json seems more common
> > and mature (certainly over something like CBOR, but I think even YAML
> > doesn't have anything nearly as nice as jq).
> 
> I'm not opposed to JSON as long as we don't write landmines.  We could
> URI-encode anything that contains a bag-of-bytes, which lets people have
> the niceties of JSON without the breakage when people don't write valid
> UTF-8.  Most things will still be human-readable.
> 
> We could even have --json be an alias for --json=encoded (URI-encoding)
> and also have --json=strict for the situation where you assert
> everything is valid UTF-8 and explicitly said you wanted us to die() if
> we saw non-UTF-8.  I don't want us to say that something is JSON and
> then emit junk, since that's a bad user experience.
> 
> Ideally, we'd have some generic serializer support for this case, so if
> people _do_ want to add YAML or CBOR output, it can be stuffed in.

Yep, I'd agree with all of that. I think we're on more-or-less the same
page.

One annoying thing about JSON is that (to my knowledge) it doesn't have
a binary data type. So you have to encode things and shove them into
"string". I guess that is not too bad if you are using backslash or
percent-encoding, as only a minority of characters get encoded. But it
sure would be nice for readers if the values, once extracted from the
json, could be used without further munging. That's most of the benefit
of using json in the first place. But it may be the best we can do.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux