-
-
Notifications
You must be signed in to change notification settings - Fork 473
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
Ignore unmapped properties in YAML #88
Conversation
Thanks for this contribution. There is definitely interest in supporting this use case. Regarding your implementation, I don't think that ObjectNodeDeserializer should depend on the naming convention, because the naming convention is already applied in the type descriptor. I think it would be better if the type inspectors stopped throwing exceptions when the property is not found, returning null instead. Then ObjectNodeDeserializer would be responsible of throwing the exception or ignoring the property, depending on the ignoreUnmatched flag. What do you think? |
Not that I have an alternative to offer, but passing null between objects isn't the best of code designs.. |
@aaubry: I can definitely work on that. @rogernorling: Sorry I don't understand. Do you mean the resulting deserialized object may have null properties, or that my implementation passes around null objects? |
@rogernorling Yes, I agree with you. That's the first idea that I came up
|
@nickbabcock: I referred to aaubry's idea to pass null to the ObjectNodeDeserializer. |
Went with a modified solution. Type inspectors return null if the property isn't found and the parameter is set to ignore unmatched. Some consideration of design: I didn't want to inject it into the constructor because then I felt like this option would have to be propagated to all decorator classes, which I felt would be overkill. I also thought about adding the property |
Merged manually in acdde89 |
Given a YAML file that contains more information than the object deserializing it, the current implementation will throw an exception because there is not a corresponding object property for all properties in the YAML file. This fixes the issue (or at least starts to address it).
It seems that there would be some interest in this solution.
Let me know what else I need to do to integrate this code.