jackson-dataformat-xml icon indicating copy to clipboard operation
jackson-dataformat-xml copied to clipboard

Java Record with @JacksonXmlText stop working with 2.18

Open akastyka opened this issue 9 months ago • 16 comments

Search before asking

  • [x] I searched in the issues and found nothing similar.

Describe the bug

Following class can't be deserialized with Jackson 2.18.2: public record Variable( @JacksonXmlProperty(isAttribute = true, localName = "name") String name, @JacksonXmlText String value) {}

deserialization fails with: Invalid definition for property '' (of type com.Variable): Could not find creator property with name '' (known Creator properties: [name, value]) at [Source: (StringReader); line: 1, column: 1]

it works with Jackson 2.17.2. Also it works with 2.18.2 but with POJO only

Version Information

2.18.2

Reproduction

-->

public record Variable(
        @JacksonXmlProperty(isAttribute = true, localName = "name") String name,
        @JacksonXmlText String value) {
    public static void deserialize() throws JsonProcessingException {
        XmlMapper xmlMapper = new XmlMapper();

        Variable deserialized = xmlMapper.readValue(
                "<jackson name=\"value\">test</jackson>", Variable.class);
        System.out.println(deserialized);
    }
}

Expected behavior

Java record is deserialized

Additional context

No response

akastyka avatar Mar 15 '25 15:03 akastyka