Skip to content

Global @JsonInclude(Include.NON_NULL) for all properties with a specific type  #1522

@CarstenWickner

Description

@CarstenWickner

When trying to optionally skip the certain fields when serialising certain beans, I put them into Java-8 Optional<> wrappers, as that's what allows me to differentiate between omitted and explicit null values on deserialisation.

As described in my respective Stackoverflow question and answer, I struggled to achieve this in a generic way via MixIns, as the (default) JacksonAnnotationIntrospector is ignoring them (at least for the @JsonInclude annotation I was looking at).
My final workaround is far from ideal, but at least works for this one isolated use case.

Are MixIns intentionally left out there or is it a bug?


Confirmed this under 2.7.4, 2.7.8, 2.8.5, and 2.8.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions