-
-
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
Class level @JsonInclude(JsonInclude.Include.NON_EMPTY)
is ignored
#1327
Comments
That would appear like a bug, at first glance. Per-class |
Similarly if |
@richturner I agree, per-property annotation should have precedence over global defaults. I assume it's easy to reproduce, if not I'll ask for repro. |
@cowtowncoder Indeed this is easy to reproduce: -
Simple POJO: -
Output serialised POJO: -
|
I see that WRITE_EMPTY_JSON_ARRAYS is deprecated from 2.8 onwards, is there an alternative global config for this? |
@richturner This should be documented better, but 2.8 introduced a way to apply From
which should have similar effect for |
As to the problem(s) here: looks like 2.7.x still works as expected, so this looks like a regression in 2.8. |
Problem was with handling of multi-level defaulting: there are no fewer than 6 levels (!) of potential inclusion settings for POJO properties now:
and care must be taken when applying overrides... turns out (1) was applied multiple times, effectively overriding later settings inappropriately. |
@JsonInclude(JsonInclude.Include.NON_EMPTY)
is ignored
Hi!
I am upgrading from Jackson 2.4.6 to 2.8.1 and I have an issue with a class level @JsonInclude annotation.
The following class runs perfectly with 2.4.6:
When I switch to 2.8.1, it does not worker anymore. The list myList is serialised as an empty list:
{"myString":"hehe","myList":[]}
I can work around that issue by moving the exclude to the field level.
I guess this is a bug? Or was the behaviour change intended?
Cheers
Ruwen
The text was updated successfully, but these errors were encountered: