Skip to content

Similar "JsonFormat.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT" but for composite types #283

Closed
@paroxysm

Description

@paroxysm

Hey guys,
So awhile ago an issue was fixed with the mapper de-serializing empty string types such as <first/> into a null, as opposed to a "".

There's also a similar issue affecting composite types as well.
Consider pseudo-xsd:

<complexType name="Parent">
  <element name="child" type="Child" maxOccurs="0"/>
</complexType>

<complexType name="Child">
 <element name="member1"/>
 <element name="member2"/>
 <element name="member3"/>
...
</complexType>

If maven-jaxb-plugin generate POJOs for this, I get pseudo-java:

@XmlType( name="Parent") class Parent {  @XmlElement(name - "child") List<Child> child }
@XmlType(name="Child") class Child { ... }

Given an XmlMapper initialized as so:

XmlMapper mapper = new XmlMapper();
AnnotationIntrospector introspector= new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
mapper.setAnnotationIntrospectors(introspector, introspector);

If I try to deserialize:
<Parent/>

I'll end up with a null object.
However, one would expect to end up with a non-null instance of "Parent", that has an empty or null list of "Child"

EDIT: Just realized I created a duplicate of #209

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions