-
Notifications
You must be signed in to change notification settings - Fork 67
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
json::serialization: don't raise errors on missing attributes with default values #2302
Conversation
Signed-off-by: Alexis Laferrière <[email protected]>
Signed-off-by: Alexis Laferrière <[email protected]>
Signed-off-by: Alexis Laferrière <[email protected]>
Signed-off-by: Alexis Laferrière <[email protected]>
…ult value Signed-off-by: Alexis Laferrière <[email protected]>
Signed-off-by: Alexis Laferrière <[email protected]>
Signed-off-by: Alexis Laferrière <[email protected]>
Signed-off-by: Alexis Laferrière <[email protected]>
c4e2aac
to
9576ee4
Compare
nice |
Cool, +1 |
Is there a possibility to add something similar to how errors are managed to know if an attribute was missing (and has been set to the default value)? I feel like being capable of knowing if the object was exactly as expected has its benefits. |
@ppepos There could be a Another alternative would be an annotation to change the behavior per attribute and make then non-optional. ( |
Option 1 seems to cover my worries. |
…with default values This PR fits in the ongoing work to improve deserializing from plain JSON objects. The JSON deserialization engine no longer raises errors on missing attributes when a default value is available. Attributes may be missing because the JSON object come from a third-party API or when loading serialized data from a previous version of the software. Default values include simple default values (`var x = 4`), lazy attributes and nullable types (which are set to `null`). This does not yet include `optional` attributes, more work would be needed. The test/example can be activated when #2296 is fixed. Pull-Request: #2302 Reviewed-by: Jean Privat <[email protected]> Reviewed-by: Alexandre Terrasa <[email protected]>
This PR fits in the ongoing work to improve deserializing from plain JSON objects.
The JSON deserialization engine no longer raises errors on missing attributes when a default value is available. Attributes may be missing because the JSON object come from a third-party API or
when loading serialized data from a previous version of the software. Default values include simple default values (
var x = 4
), lazy attributes and nullable types (which are set tonull
). This does not yet includeoptional
attributes, more work would be needed.The test/example can be activated when #2296 is fixed.