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.

Curl will now output JSON

120 pointsby logicalstackabout 5 years ago

9 comments

dTalabout 5 years ago
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 未加载
enriqutoabout 5 years ago
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>
quintonishabout 5 years ago
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>
theMiddleBlueabout 5 years ago
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 未加载
rossmohaxabout 5 years ago
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.
MuffinFlavoredabout 5 years ago
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 未加载
pyuser583about 5 years ago
That’s nice.
monkey26about 5 years ago
To bad this requires nightly.
omaniabout 5 years ago
beautiful. thank you for this.