TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Jo - JSON output from a shell

138 点作者 fcambus大约 9 年前

5 条评论

networked大约 9 年前
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.
dm3大约 9 年前
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 未加载
techdragon大约 9 年前
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 未加载
dansimau大约 9 年前
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 未加载
zimbatm大约 9 年前
`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>