-
-
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
Include.NON_DEFAULT doesn't work for value types, 2.7.0 and up #1663
Comments
Oddly, Jackson >= 2.7.0 does behave properly if |
@shawjef3 This may be matter of documentation. Specifically: if applied to a field (or as global default), it will only prune type-default: so for So: if applied to property, default value to filter is whatever default type has: if to enclosing POJO class, value that property has for that POJO's default instance (one constructed with zero-arg constructor). |
@cowtowncoder Thanks, I see the difference. Are you sure it's supposed to be that way vs. the old way? I don't see anything in the 2.7.0 changelog about it, yet it changed with version 2.7.0. The reason I'm bringing this up as a bug, is that I upgraded some code from 2.4 to the latest version, and the change in how defaults are serialized broke some tests. |
Hi @cowtowncoder, I tried using
It still serializes the Date as 0 instead of excluding it. I have included my code below.
|
@shawjef3 Part of the problem here is that some changes may have been regressions; and in other cases clarifications to rules may not have explicitly matching issues filed. But the big thing that was documented on https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.7 was #952 (Revert back expansion of NON_EMPTY handling), and some changes may stem from that one. |
@uberstud87 Could you please file a separate issue for this: while these things appear possibly related, I think there is specific thing about |
@cowtowncoder I have filed a separate issue #1676 as you advised. |
@cowtowncoder , which version has the fix of using non_empty property with integer such that 0 isn't omitted out from the output? |
@akanssha1 I do not remember off-hand for sure, but 2.9 and 2.10 certainly. My guess is that'd be in 2.8.0 as well. |
Since behavior change is now pretty old, new behavior is considered the default; closing this issue. |
Please see the project at https://github.com/shawjef3/jackson-default-bug. It has a single test, which fails for Jackson 2.7.0 and higher, but succeeds for lower versions.
In the above an ObjectMapper will include "i" in the resulting json if
i
is 1, but not ifi
is 0. This behavior is reversed for versions below 2.7.0. I believe if the default is 1, as in the above code, it should not be included when the actual value is 1.The text was updated successfully, but these errors were encountered: