You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I have faced a minor issue when using JsonUnwrapped annotation together with a custom null value: null value is ignored when serializing nested objects. Here comes an example:
importcom.fasterxml.jackson.annotation.JsonUnwrapped;
importcom.fasterxml.jackson.core.JsonProcessingException;
importcom.fasterxml.jackson.dataformat.csv.CsvMapper;
importcom.fasterxml.jackson.dataformat.csv.CsvSchema;
classInner {
publicStringf1;
publicStringf2;
publicStringf3;
}
classOuter {
publicStringf1;
@JsonUnwrappedpublicInnerf2;
}
publicclassTest {
publicstaticvoidmain(Stringargs[]) throwsJsonProcessingException {
finalCsvMappermapper = newCsvMapper();
// Set null value to 'null'finalCsvSchemaschema = mapper.schemaFor(Outer.class).withNullValue("null");
// Create an object. All the fields are NULLsfinalOuterouter = newOuter();
// Serialize the object.// I would expect: null,null,null,null// I get: null,,,System.out.println(mapper.writer(schema).writeValueAsString(outer));
}
}
Hi. I have faced a minor issue when using JsonUnwrapped annotation together with a custom null value: null value is ignored when serializing nested objects. Here comes an example: