Hi Yacine,

On 7 November 2014 10:56, Yacine Kheddache <yacine.khedda...@alyseo.com> wrote:
> Please check this out and let us know what you are thinking about it :
> https://github.com/Alyseo/zfs/tree/json

I took a look at the code.  I like that the entire JSON object appears
on one line, in keeping with the popular pattern of
"linefeed-delimited JSON" used by tools like bunyan[1].  I think the
output would be better without the needless whitespace between keys,
values, colons, etc.

I think there's a deeper problem with this relatively simplistic
approach to generating JSON: the encoding of non-printing characters,
or characters beyond the 7-bit ASCII space.  You really need to escape
both key and value strings, and possibly deal with locales, etc.  The
safest subset of UTF-8 for use here is 7-bit ASCII, with numeric
escape sequences for characters beyond that in the Basic Multilingual
Plane.

I know Robert mentioned to you earlier that we already have code in
libnvpair, and thus available to OpenZFS in general, to take an
nvlist_t and emit it as JSON.  This code does deal (at least
minimally) with the escaping of strings:

  
https://github.com/joyent/illumos-joyent/blob/master/usr/src/lib/libnvpair/nvpair_json.c#L29-L109

I like the idea in general, we just need to agree on a correct and
well-specified output format (and implementation) if we are
introducing new Public flags to zpool(1M) and zfs(1M) -- especially as
this output is for programmatic consumption.


Thanks.


[1]: https://github.com/trentm/node-bunyan

-- 
Joshua M. Clulow
UNIX Admin/Developer
http://blog.sysmgr.org
_______________________________________________
developer mailing list
developer@open-zfs.org
http://lists.open-zfs.org/mailman/listinfo/developer

Reply via email to