Skip to content

Exception when parsing Lists of mixed content (since 2.13.0)Β #509

@cornwe19

Description

@cornwe19

In Jackson 2.12 the following junit example test (written in Kotlin) works as I'd expect it to

@JsonIgnoreProperties(ignoreUnknown = true)
data class Tspan(
    @field:JacksonXmlText
    var content: String? = null
)

@JsonIgnoreProperties(ignoreUnknown = true)
class Text(
    @field:JacksonXmlElementWrapper(useWrapping = false)
    @field:JacksonXmlProperty(localName = "tspan")
    var spans: List<Tspan>? = null
)

class ExampleTest {
    @Test
    fun svgExample() {
        val text = XmlMapper().readValue("<text>Mixed <tspan>content</tspan> should<tspan> work</tspan></text>", Text::class.java)

        assertThat(text.spans, hasSize(2))
    }
}

But when I upgrade to 2.13, I get the following error

Unexpected non-whitespace text (' should' in Array context: should not occur (or should be handled)
 at [Source: (StringReader); line: 1, column: 49] (through reference chain: com.visualdx.api.kmax.graphql.Text["tspan"])
com.fasterxml.jackson.databind.JsonMappingException: Unexpected non-whitespace text (' should' in Array context: should not occur (or should be handled)
 at [Source: (StringReader); line: 1, column: 49] (through reference chain: com.visualdx.api.kmax.graphql.Text["tspan"])

This feels like a bug, but I'm not sure if there's some workaround or setting I'm missing somewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.16For issues planned for 2.16

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions