Closed
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
After upgrading to 2.18.0, empty Strings/objects are no longer included in json output if NON_DEFAULT annotation is used on the class and the default value is null. This is possibly related to fixing #4464
As far as I can understand, the documentation states that the test below should pass, as it does in 2.17.1.
Version Information
2.18.0
Reproduction
@Test
void testSerialization() throws JsonProcessingException {
MyString input = new MyString();
input.setValue("");
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(input);
MyString output = objectMapper.readValue(json, MyString.class);
assertEquals(input.getValue(), output.getValue());
}
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@Data
public static class MyString {
private String value = null;
}
Expected behavior
No response
Additional context
No response