-
-
Notifications
You must be signed in to change notification settings - Fork 230
Closed
Milestone
Description
I have defined a List of Objects in a POJO:
public class Order {
@JacksonXmlElementWrapper(localName = "line_items")
@JacksonXmlProperty(localName = "line_item")
private List<LineItem> line_items = null;
}
Normally this Element will be serialized like this if it is not null (this works as expected and is ok):
<order>
<line_items>
<line_item>...</line_item>
</line_items>
</order>
But if the List is provided as null it will be serialized like this (tested with Jackson 2.3.1):
<order>
<line_item/>
</order>
But correct would be:
<order>
<line_items/>
</order>
I also found a hint in the comments of the jackson-code :-)
See XMLBeanPropertyWriter:
/* Hmmh. Does the default null serialization work ok here? For now let's assume
* it does; can change later if not.
*/
if (value == null) {
if (_nullSerializer != null) {
jgen.writeFieldName(_name);
_nullSerializer.serialize(null, jgen, prov);
}
return;
}
Metadata
Metadata
Assignees
Labels
No labels