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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Easy CLI JSON Formatting

33 点作者 sublimino超过 12 年前

9 条评论

bryanlarsen超过 12 年前
Couple dozen other ways to do it: <a href="http://stackoverflow.com/questions/352098/how-to-pretty-print-json-script/5006476" rel="nofollow">http://stackoverflow.com/questions/352098/how-to-pretty-prin...</a>
cobralibre超过 12 年前
A problem with piping curl output through "python -mjson.tool" is that you can't include the response headers, which is sometimes useful.<p>(This was enough of a problem for me that I wrote a simple curl replacement in Python so I could have pretty-printed JSON or XML <i>and</i> response headers, <i>or</i> send the response directly to a Python REPL console as an object: <a href="https://github.com/cobralibre/hotpotato" rel="nofollow">https://github.com/cobralibre/hotpotato</a> )
评论 #4763044 未加载
kmfrk超过 12 年前
Here is Paul Irish's .function dotfile solution: <a href="https://github.com/paulirish/dotfiles/blob/master/.functions#L55" rel="nofollow">https://github.com/paulirish/dotfiles/blob/master/.functions...</a>.<p>Really recommend setting up his dotfiles. After you back up your dotfiles, you can install his (which overwrites yours) just by writing<p><pre><code> git clone https://github.com/paulirish/dotfiles.git &#38;&#38; cd dotfiles &#38;&#38; ./sync.sh</code></pre>
DougBTX超过 12 年前
This is another good one for formatting / filtering json: <a href="http://stedolan.github.com/jq/" rel="nofollow">http://stedolan.github.com/jq/</a>
tedchs超过 12 年前
Here is the bash alias I have been using for CLI JSON formatting, and as a bonus, my random password generator:<p>alias jsonpp='ruby -r json -e '\''puts JSON.pretty_generate(JSON.parse(STDIN.read))'\'''<p>alias md5pass='dd if=/dev/random bs=100 count=1 2&#62;/dev/null | md5'
exhuma超过 12 年前
I've done something similar a while back. A simple "works-for-me" package. Feel free to try it out:<p><a href="https://github.com/exhuma/braindump/tree/master/jsonformat" rel="nofollow">https://github.com/exhuma/braindump/tree/master/jsonformat</a>
acdha超过 12 年前
httpie is a nice replacement for curl which, among other things, has built-in formatting so you can get pretty JSON / XML responses without giving up your ability to do things like displaying response headers:<p><a href="https://github.com/jkbr/httpie" rel="nofollow">https://github.com/jkbr/httpie</a>
Argorak超过 12 年前
I use jazor and coderay for that:<p>gem install jazor coderay<p>curl $SOMETHING | jazor | coderay -json
wooptoo超过 12 年前
Or with jsonlist in NodeJS.