4 ms·
The Juniper libxo [1] library is an interesting approach which preserves the traditional text output but also gives an option to output structured data: The
by _paulc 12y ago
The Juniper libxo [1] library is an interesting approach which preserves the traditional text output but also gives an option to output structured data:
The libxo library allows an application to generate text,
XML, JSON, and HTML output using a common set of function
calls. The application decides at run time which output
style should be produced.
There is some work ongoing to convert FreeBSD utilities to support libxo [2] and a long thread on freebsd-arch [3]
[1] https://juniper.github.io/libxo/libxo-manual.html https://juniper.github.io/libxo/libxo-manual.html
[2] https://wiki.freebsd.org/LibXo https://wiki.freebsd.org/LibXo
[3] https://lists.freebsd.org/pipermail/freebsd-arch/2014-July/015633.html https://lists.freebsd.org/pipermail/freebsd-arch/2014-July/0...
- xenophonf 12y agoI've just started working with the new AWS CLI, and while in the long term I will probably switch to using boto directly from Python, for now I process the CLI's JSON output in bash scripts. Using structured data in this way is really quite interesting. Because it isn't sensitive to whitespace or newline mangling, the JSON output can safely be stored in an environment variable a la Perl (e.g., ```VAR=$(aws ... -output json)```). Rather than hacking up some rudimentary parsing using sed/awk/etc., I can pipe it to an existing parser (e.g., jshon), which will extract the data I want with minimal effort. I think that if I had an objection to XML, it isn't because it's structured but because it's so verbose relative to simpler serialization formats like JSON or YAML. Then again, I don't know why we even bother with those when we're just a tiny bit of syntax away from sexps. :)
- deleted 12y ago[deleted]
- jcrites 12y agoI've also found the utility called jq [1] to be a great help working with JSON data on the CLI, such as from the AWS CLI. It's great at parsing and selecting output, or performing simple transformations. [1] http://stedolan.github.io/jq/ http://stedolan.github.io/jq/