Skip to content

Add support for @JsonInclude(content=Include.NON_NULL) (and NON_EMPTY) for Maps #527

@cowtowncoder

Description

@cowtowncoder

(and other inclusion values)

Currently use of something like:

@JsonInclude(Include.NON_EMPTY)

only affects value itself. But for structured values (arrays, Collections, Maps), there is also the question of inclusion strategy for contents.
Currently the only way to control such inclusion is via global feature SerializationFeature.WRITE_NULL_MAP_VALUES, and that only affects handling of Maps.

But it would seem reasonable to add an additional property in @JsonInclude, say, contents, and modify structured type serializers to consider this for filtering.
The first one to use it with should be Map (and specialized variants like EnumMap). But due to amount of work involved, let's add support for arrays and Collections if and when specifically requested.

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