-
Notifications
You must be signed in to change notification settings - Fork 6
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
set default value if null (or meet some condition) in deserialization #39
Comments
Since Jackson 2.9, there is https://medium.com/@cowtowncoder/jackson-2-9-features-b2a19029e9ff and probably covers some of the use cases. This does not quite cover cases that might occur here but I mention it in any case anyone is looking for existing functionality. Other than that, we have no current plans to extend value handling towards configurable defaults: the main approach is to expect POJOs to be constructed with defaults -- this coupled with |
Can we have Then I could do This would then effectively be the full inverse of |
Yes, if this feature was implemented one possibility could be to use constant like that. |
Are we thinking of doing a |
@swayamraina I think this is what is requested. |
I'm wondering if we can have an annotation (field level and class level) to set a default value if the corresponding JSON value is null in deserialization.
After deserialization, We can have people.name == "Jack" and people.age == 10.
After deserialization, We can have people.name == "Jack", people.age == 0 and people.weight == 0.0
The text was updated successfully, but these errors were encountered: