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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Curl will now output JSON

120 点作者 logicalstack大约 5 年前

9 条评论

dTal大约 5 年前
I think if all command line tools outputted JSON, it would go a long way towards fixing the "ad-hoc parser problem" in scripts, and bring unixy shells around to a more PowerShell-like object-passing style. Passing plain text around is a great idea, but It's silly to restrict yourself to a single structural unit within that text (the "line"). We have better tech now.
评论 #22610717 未加载
评论 #22610283 未加载
评论 #22611207 未加载
评论 #22609226 未加载
评论 #22614732 未加载
评论 #22613784 未加载
评论 #22609981 未加载
enriquto大约 5 年前
No need to panic! You can still pipe it to gron [0] and recover useable output.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;TomNomNom&#x2F;gron" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;TomNomNom&#x2F;gron</a>
quintonish大约 5 年前
Note that this is not titled, &quot;Curl will now format JSON&quot;. This will &quot;Make curl display information on stdout after a completed transfer&quot;[1].<p>[1] <a href="https:&#x2F;&#x2F;curl.haxx.se&#x2F;docs&#x2F;manpage.html#-w" rel="nofollow">https:&#x2F;&#x2F;curl.haxx.se&#x2F;docs&#x2F;manpage.html#-w</a>
theMiddleBlue大约 5 年前
I&#x27;m testing it, maybe I&#x27;m doing it wrong but I don&#x27;t understand well if it&#x27;s possible to show only the json output (and not both json and response body). I&#x27;m doing it with a trick:<p>curl -I -XGET -w &#x27;%{json}&#x27; <a href="https:&#x2F;&#x2F;www.google.com" rel="nofollow">https:&#x2F;&#x2F;www.google.com</a> | tail -1 | jq
评论 #22613689 未加载
rossmohax大约 5 年前
It is a step in the right direction, but still far from all the goodnes of PowerShell&#x27;s Invoke-WebRequest . Not sure curl can do anything about it though.
MuffinFlavored大约 5 年前
Do you still need to pass it to `jq` for it to be pretty printed or no, I couldn&#x27;t tell from reading the article?
评论 #22611023 未加载
pyuser583大约 5 年前
That’s nice.
monkey26大约 5 年前
To bad this requires nightly.
omani大约 5 年前
beautiful. thank you for this.