Skip to content

Allow setting SerializationInclusion with JsonInclude.Value #24824

Closed
@vkuzel

Description

@vkuzel

Affects: \5.2.5
Enhancement

  • There is a method Jackson2ObjectMapperBuilder.serializationInclusion(JsonInclude.Include serializationInclusion) which is an equivalent to Jackson's ObjectMapper setSerializationInclusion(JsonInclude.Include incl)
  • Unfortunately there is no equivalent to ObjectMapper.setPropertyInclusion(JsonInclude.Value incl) which allows more elaborate configuration.

Suggestion #1

  • Replace (or add) Jackson2ObjectMapperBuilder.serializationInclusion(JsonInclude.Include serializationInclusion) with Jackson2ObjectMapperBuilder.serializationInclusion(JsonInclude.Value serializationInclusion) which covers more cases.

Suggestion #2

  • Add an object mapper post-processor to Jackson2ObjectMapperBuilder which would allow to perform exotic configurations not supported by builder by default.
  • This would remove the need of extending builder class which comes handy in Spring Boot applications.
//example
class Jackson2ObjectMapperBuilder {

    private Consumer<ObjectMapper> postProcessor;

    public void configure(ObjectMapper objectMapper) {
        // ...
        if (postProcessor != null) {
            postProcessor.accept(objectMapper);
        }
    }

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions