TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Jo - JSON output from a shell

138 pointsby fcambusabout 9 years ago

5 comments

networkedabout 9 years ago
Neat. An ad hoc alternative to this if you have Python 2.7 handy and can&#x27;t or don&#x27;t want to compile C code could be something like<p><pre><code> $ python -c &#x27;import json, sys;\ kv = sys.argv[1::];\ v = [int(x) if x.isdigit() else eval(x.title()) if x in [&quot;false&quot;, &quot;true&quot;]\ else x for x in kv[1::2]];\ print json.dumps(dict(zip(kv[::2], v)), ensure_ascii=False, indent=2) &#x27; key1 value1 key2 &#x27;string value 2&#x27; number 5589 boolean1 true boolean2 false </code></pre> which produces the output<p><pre><code> { &quot;key2&quot;: &quot;string value 2&quot;, &quot;key1&quot;: &quot;value1&quot;, &quot;number&quot;: 5589, &quot;boolean2&quot;: false, &quot;boolean1&quot;: true } </code></pre> I, for one, am excited to hear that native JSON (and XML, and HTML) output is coming to FreeBSD&#x27;s userland courtesy of libxo (see <a href="https:&#x2F;&#x2F;wiki.freebsd.org&#x2F;LibXo" rel="nofollow">https:&#x2F;&#x2F;wiki.freebsd.org&#x2F;LibXo</a>). I hope GNU Core Utilities eventually go the same way or a full-featured alternative appears for Linux that does.
dm3about 9 years ago
Very nice. This looks like a great complement to `jt` (<a href="https:&#x2F;&#x2F;github.com&#x2F;micha&#x2F;json-table" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;micha&#x2F;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.
评论 #11274324 未加载
评论 #11274365 未加载
techdragonabout 9 years ago
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 &#x27;Jo&#x27;, but I also think the tool creates JSON, so why not call it `json` or `jp` short for &#x27;json print&#x27; ... but the matter appears settled. Oh well.
评论 #11273359 未加载
评论 #11273175 未加载
dansimauabout 9 years ago
Awesome looking tool. One thing I noticed, however:<p><pre><code> $ false; echo success@$? | jo {&quot;success&quot;:true} </code></pre> i.e. jo&#x27;s translation of integers to booleans does not match that of a typical shell.
评论 #11273400 未加载
zimbatmabout 9 years ago
`jo` is conflicting with autojump on my system.<p>Other than that it looks pretty handy.<p><pre><code> ls | jo -a -B</code></pre>