News for hackers. Stuff that matters.
Re:Jo - JSON output from a shell by networked on Saturday March 12, 2016 @12:26PM (#11273634)
Neat. An ad hoc alternative to this if you have Python 2.7 handy and can't or don't want to compile C code could be something like

  $ python -c 'import json, sys;\
  kv = sys.argv[1::];\
  v = [int(x) if x.isdigit() else eval(x.title()) if x in ["false", "true"]\
      else x for x in kv[1::2]];\
  print json.dumps(dict(zip(kv[::2], v)), ensure_ascii=False, indent=2)
 ' key1 value1 key2 'string value 2' number 5589 boolean1 true boolean2 false
which produces the output

  {
    "key2": "string value 2", 
    "key1": "value1", 
    "number": 5589, 
    "boolean2": false, 
    "boolean1": true
  }
I, for one, am excited to hear that native JSON (and XML, and HTML) output is coming to FreeBSD's userland courtesy of libxo (see https://wiki.freebsd.org/LibXo). I hope GNU Core Utilities eventually go the same way or a full-featured alternative appears for Linux that does.

There are no comments on this comment yet.