-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
When Include.NON_DEFAULT
setting is used on POJO, empty values are not included in json if default is null
#4741
Comments
That annotation has this in the javadoc:
I don't think this annotation value is about nulls - there are other annotation values you can use. If you look at the test cases in jackson-databind, you will see that none of the tests related to Have a look at https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-annotations/latest/index.html You could try You say that the behaviour of Include.NON_DEFAULT has changed in Jackson 2.18 and that needs investigation. |
I created #4743 which does demo your issue. I have verified that 2.18 behaves differently. |
Reasonably good chance that this relates to #4464 |
Hello, we have the same problem. We have lots of pojos, where the default value is
Sorry, I do think so, as this is clearly mentioned in the javadoc
Roland |
Tough call... seems like everyone has their own interpretation of the JavaDoc. |
The documentation states that the behavior depends on context. I believe that the context is different in this case and @teodord 's case. The POJO case should include empty strings, the global case should not. |
I concur. I might as well re-read the documentation one more time and see what we can do to fix the regression later today. Thank you for explanting this @ragnhov @rPraml @pjfanning ! |
Okay, re-reading through the documentation I am leaning toward towards keeping both behavior, thus #4744. I would like to ask @cowtowncoder for direction we should head, while I am going back to re-examine the documentation-behavior sync one more time. EDIT : Yup, it seems like both this issue and #4464 are meant to be suuported. This issue about per-POJO cases and latter about global setting. |
On this particular case: in this example if POJO has |
Include.NON_DEFAULT
setting is used on POJO, empty values are not included in json if default is null
…empty values are not included in json if default is null (#4744)
Fixed for 2.18.1 |
Search before asking
Describe the bug
After upgrading to 2.18.0, empty Strings/objects are no longer included in json output if NON_DEFAULT annotation is used on the class and the default value is null. This is possibly related to fixing #4464
As far as I can understand, the documentation states that the test below should pass, as it does in 2.17.1.
Version Information
2.18.0
Reproduction
Expected behavior
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: