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<p><pre><code> $ 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
</code></pre>
which produces the output<p><pre><code> {
"key2": "string value 2",
"key1": "value1",
"number": 5589,
"boolean2": false,
"boolean1": true
}
</code></pre>
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 <a href="https://wiki.freebsd.org/LibXo" rel="nofollow">https://wiki.freebsd.org/LibXo</a>). I hope GNU Core Utilities eventually go the same way or a full-featured alternative appears for Linux that does.
Very nice. This looks like a great complement to `jt` (<a href="https://github.com/micha/json-table" rel="nofollow">https://github.com/micha/json-table</a>) - a tool to turn JSON into plain text tables. Both seem to be super simple tools written in C with no heavy dependencies.
Awesome complimentary program to the `jq` tool.<p>However... I do wish the name was `json` not `jo`. In my case more for personal reasons regarding painful memories attached to the name 'Jo', but I also think the tool creates JSON, so why not call it `json` or `jp` short for 'json print' ... but the matter appears settled. Oh well.
Awesome looking tool. One thing I noticed, however:<p><pre><code> $ false; echo success@$? | jo
{"success":true}
</code></pre>
i.e. jo's translation of integers to booleans does not match that of a typical shell.