We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'm trying to parse a json string looks like this
{ "a": { "a": 1 }, "b": { "b": 2 } }
The code I used follows
char buff[] = "{\"a\":{\"a\":1},\"b\":{\"b\":2}}"; int len = sizeof(buff); int a = 0, b = 0; json_scanf(buff, len, "{a:{a:%d},b:{b:%d}}", &a, &b); printf("a %d b %d\n", a, b);
outputs
a 1 b 0
Only a got parsed. Any idea on how to also parse b?
a
b
The text was updated successfully, but these errors were encountered:
I have the same issue. I can write my data out like this:
json_fprintf(_configLoaded, "{" "background:{ red:%f, green:%f, blue:%f }," "content:{ x:%d, y:%d, w:%d, h:%d }," "window:{ x:%d, y:%d, w:%d, h:%d }," "lastProject:%Q, notes:%Q, showNotepad:%B, style:%d, version:%d" "}", __config.background.red, __config.background.green, __config.background.blue, __config.content.x, __config.content.y, __config.content.w, __config.content.h, __config.window.x, __config.window.y, __config.window.w, __config.window.h, __config.lastProject, __config.notes.text, __config.showNotepad, __config.style, __config.version );
But reading requires:
json_scanf(buffer, strlen(buffer), "{ background:{ red:%f, green:%f, blue:%f } }", &__config.background.red, &__config.background.green, &__config.background.blue); json_scanf(buffer, strlen(buffer), "{ content:{ x:%d, y:%d, w:%d, h:%d } }", &__config.content.x, &__config.content.y, &__config.content.w, &__config.content.h); json_scanf(buffer, strlen(buffer), "{ window:{ x:%d, y:%d, w:%d, h:%d } }", &__config.window.x, &__config.window.y, &__config.window.w, &__config.window.h); json_scanf(buffer, strlen(buffer), "{ lastProject:%Q, notes:%Q, showNotepad:%B, style:%d, version:%d }", &__config.lastProject, &__config.notes.text, &__config.showNotepad, &__config.style, &__config.version);
Otherwise, only "background" is filled in.
Sorry, something went wrong.
No branches or pull requests
I'm trying to parse a json string looks like this
The code I used follows
outputs
Only
a
got parsed. Any idea on how to also parseb
?The text was updated successfully, but these errors were encountered: