-
Notifications
You must be signed in to change notification settings - Fork 80
json output not properly quoted #340
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
>>>> "baikal" == baikal ***@***.***> writes:
duc json somepath emits json where at least " and are not properly
quoted by in the json, which makes json invalid ...
Can you please give me more details and I'll see if I can come up with
a patch against v1.5.0-rc1, especially since I'm not up on all the
JSON requirements directly.
… —
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.*Message ID: <zevv/duc/issues/340
@github.com>
baikalbaikal created an issue (zevv/duc#340)
duc json somepath
emits json where at least " and are not properly quoted by in the json, which makes json invalid
...
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.*Message ID: <zevv/duc/issues/340
@github.com>
|
The following patch solves it for " (double quote), TAB, CR and LF characters. Although there might be more (all < ascii 32 ?).
|
wait, make that the following, according to here:
|
haha yes the original escaping was just utter nonsense, i wonder how we let that creep in without noticing. thanks for reporting! |
>>>> "Ico" == Ico Doornekamp ***@***.***> writes:
haha yes the original escaping was just utter nonsense, i wonder how
we let that creep in without noticing. thanks for reporting!
I wonder how... anyway, thanks for the patches and the test cases! I
wonder if we should try using 'jsonlint' or some other lint-like tool
for doing some more validations here?
As you can guess, I haven't had a chance to look at this, but I will
work on applying the patch this weekend and getting out a new release
if I can find the time.
1.5.0-rc2 I suspect. But with some big holes still.
|
Quoting John (2025-04-05 02:38:30)
l8gravely left a comment (zevv/duc#340)
>>>>> "Ico" == Ico Doornekamp ***@***.***> writes:
> haha yes the original escaping was just utter nonsense, i wonder how
> we let that creep in without noticing. thanks for reporting!
I wonder how...
My apologies if that sounded a lot like I was blaming someone else for
not noticing this. The thing is, it seems that I reviewed and merged
this myself on july 23d, 2022, so that perfectly explains the "how" :)
https://www.json.org/json-en.html is pretty clear about the proper way
to handle this, so I propose this so we also handle the control
characters:
```
static void print_escaped(const char *s)
{
const char *p = s;
while(*p) {
if(*p == '"' ) printf("\\\"");
else if(*p == '\\') printf("\\\\");
else if(*p == '\b') printf("\\b");
else if(*p == '\f') printf("\\f");
else if(*p == '\n') printf("\\n");
else if(*p == '\r') printf("\\r");
else if(*p == '\t') printf("\\t");
else if(*p < 0x20) printf("\\u%04x", *p);
else putchar(*p);
p++;
}
}
```
We might still be lacking on the UTF-8 side, but we can always pick that
up if we run into it later.
anyway, thanks for the patches and the test cases! I wonder if we
should try using 'jsonlint' or some other lint-like tool for doing
some more validations here?
That makes sense, good plan.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
duc json somepath
emits json where at least " and are not properly quoted by in the json, which makes json invalid ...
The text was updated successfully, but these errors were encountered: