-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
7.76.1 outputs invalid JSON in --write-out %{json}
(a few versions back it was still fine)
#6905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Lines 260 to 272 in 566b74a
I think I was trying to imitate the existing non-json --write-out for the http codes. diff --git a/src/tool_writeout.c b/src/tool_writeout.c
index 5296778..ed7a341 100644
--- a/src/tool_writeout.c
+++ b/src/tool_writeout.c
@@ -259,12 +259,13 @@ static int writeLong(FILE *stream, const struct writeoutvar *wovar,
if(valid) {
if(use_json)
- fprintf(stream, "\"%s\":", wovar->name);
-
- if(wovar->id == VAR_HTTP_CODE || wovar->id == VAR_HTTP_CODE_PROXY)
- fprintf(stream, "%03ld", longinfo);
- else
- fprintf(stream, "%ld", longinfo);
+ fprintf(stream, "\"%s\":%ld", wovar->name, longinfo);
+ else {
+ if(wovar->id == VAR_HTTP_CODE || wovar->id == VAR_HTTP_CODE_PROXY)
+ fprintf(stream, "%03ld", longinfo);
+ else
+ fprintf(stream, "%ld", longinfo);
+ }
}
else {
if(use_json) |
Is the problem that the number is zero-prefixed? BTW, 'jq' parses this fine... |
(sorry, wrong button) |
seems so |
Make sure one of the azure jobs has jsonlint installed so that the test runs there. Ref: #6905
Yes. Testing using
|
Make sure one of the azure jobs has jsonlint installed so that the test runs there. Ref: #6905
@bagder @jay I encountered the same issue with 2 more fields:
Looking at the diff of the fix, I think they should be covered as well, but asking just to make sure. Thank you for a quick fix! |
yes |
I did this
Notice this part:
"http_connect":000
This is not valid JSON, and it breaks different parsers:
json.loads()
,Perhaps you could add a unit test to verify said JSON validity with some external tool?
I expected the following
Valid JSON.
curl/libcurl version
operating system
alpine:3.13.2
on:The text was updated successfully, but these errors were encountered: