curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: -w %{JSON}

From: Ray Satiro via curl-users <>
Date: Sun, 24 May 2020 19:08:17 -0400

On 5/24/2020 1:10 PM, Коваленко Анатолий Викторович via curl-users wrote:
> About #5435.
> The last version on is 7.70.0 from 2020-04-29. At this version error
> NOT corrected. My script have to check this situation and I wait the NEW version. Is it wrong too?
> Sorry, I simply do not understand.
> 2020-05-21 Daniel Stenberg wrote for me, that curl output have not JSON format in common case. That
> is citation from him letter.
> My question: is there any other output beyond «Saved to filename» and «--write-out»?
> Stenberg's answer: You mean*ever* ? Yes. But in for your use case? I don't think so...
> That is why I ask that the ALL curl output always be in the SAME format. Not just «-w» variables,
> but ALL output. It is possible to make so?
> ====================================================================================================
> At last. Separate the content and format. Make JSON/NotJSON applicable to ALL output, and give the
> unconditional (obligatory?) opportunity to choice «-w» variables: all or some from list.
> JSON – format only, not content. The choice of all or some variables – independently from they
> format.
> ====================================================================================================
> Thank you for your attention and sorry my English.
>> On 5/23/2020 3:10 PM, Коваленко Анатолий Викторович via curl-users wrote:
>>> The curl output is not identical JSON, read manual carefully.
>>> I ask how in the curl output to find the right JSON. And must I to find one string or many ones.
>>> Must I check ALL POSSIBLE subsequences of text for JSON formatting? Nonsense.
>>> Read question carefully, please. Do not answer to you own question, answer to my one.
>> Please don't top-post it makes the conversation hard to follow. [1]
>> Once #5435 is fixed there should not be other output to stdout for your
>> command. [2]
>> I suggest use the --silent option. [3]
>> [1]:
>> [2]:
>> [3]:

The fix will be in the next version of curl which is scheduled to be
released in one month. Use --silent so that informational messages are
not sent to stdout/stderr.

There is no built-in way to output only some write-out variables as
json, but you could do it yourself for some info variables:

"{\"http_code\": %{http_code}}"

As Daniel said earlier if you output %{json} it contains all name/values
and you parse it. That is the way to do it.

Please stop top-posting.

Received on 2020-05-25