-
Notifications
You must be signed in to change notification settings - Fork 54
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
does parseTo check struct members ? #28
Comments
This will not work since there is no metadata on the struct. You will have to add a JS_OBJ macro or a JS_OBJ_EXT. I think these kind of questions a well suited for in the new "Discussions" forum. Check it out here: |
I have add JS_OBJ macro, |
Oh! I see what you mean. So the names of the JSON members will be the same as the C++ struct members when you use the JS_OBJ macro. If you don't want to use the same name then you will have to use the JS_MEMBER_WITH_NAME or JS_MEMBER_ALIASES macro style. Its use is described in this example: So your struct a will make a json object with a member called a "ie: { "a": 19 }, but your struct b has a member called b. And when parsing the JSON into the struct b it cant find a member called a, only a member called b. |
Also in your example you are trying to send in the type name, ie a and not s_a and b not s_b. |
Yes ,you are right. |
https://github.com/jorgen/json_struct/blob/master/tests/json-struct-optional.cpp JS::ParseContext context(json, sizeof(json));
context.allow_missing_members = false;
context.allow_unnasigned_required_members = false; try this. |
for example
the code give me no error,
but s_b.b is still zero.
The text was updated successfully, but these errors were encountered: