" + "

Xsi nil in collection fails to deserialize · Issue #353 · FasterXML/jackson-dataformat-xml (original) (raw)

I can't deserialize xsi:nil in collections. I use jackson 2.9.8

Sample test to reproduce it:

`class NilTest {

@Test
void shouldDeserialize() throws IOException {
    String xml = "" +
            "<A>" +
            "  <c xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true'/>" + // no problems with this one
            "  <e>ee</e>" +
            "  <B>" +
            "    <d>dd</d>" +
            "  </B>" +
            "  <B>" +
            "    <d xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true'/>" + // fails in collections
            "    <f>ff</f>" +
            "  </B>" +
            "</A>";
    XmlMapper mapper = new XmlMapper();

    A result = mapper.readValue(xml, A.class);

    assertNotNull(result);
}

@Setter
static class A {
    private String c;
    private String e;
    @JsonProperty("B")
    @JacksonXmlElementWrapper(useWrapping = false)
    private List<B> bs;
}

@Setter
static class B {
    private String d;
    private String f;
}

}`

Exception:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of NilTest$B (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('ff')
at [Source: (StringReader); line: 1, column: 205] (through reference chain: NilTest$A["B"]->java.util.ArrayList[2])