Skip to content

Remove ObjectMapper.setSerializationInclusion() from 3.0 (deprecate in 2.20) #5270

@cowtowncoder

Description

@cowtowncoder

(note: this is retroactive issue -- actual removal done before 3.0.0-rc1 release)
(note: inspired by #5269)

With 3.0, ObjectMapper becomes immutable: this is achieved by removing all setXxx() methods (and other mutators). This includes setSerializationInclusion().

The replacement for:

ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

is

ObjectMapper mapper = JsonMapper.builder()
    .changeDefaultPropertyInclusion(incl -> incl.withValueInclusion(JsonInclude.Include.NON_NULL)
    .build();

NOTE: it may make sense to create an umbrella issue for "make ObjectMapper immutable"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.0Issue planned for initial 3.0 release3.0-release-notesIssues relevant for 3.0 release notes.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions