Skip to content

What the replacement of serializationInclusion(JsonInclude.Include.NON_EMPTY) in Jackson 3.0 #282

Closed Answered by pjfanning
hantsy asked this question in Q&A
Discussion options

You must be logged in to vote

I found a test case that uses serializationInclusion in Jackson 2 and found its equivalent in Jackson 3 (JsonInclude4464Test).

This test case changes its setup for 3.x to this:

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

in 2.x this was,

        ObjectMapper mapper = JsonMapper.builder().serializationInclusion(JsonInclude.Include.NON_DEFAULT).build();

Obviously, this uses NON_DEFAULT but NON_EMPTY can be set in a similar way.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hantsy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants