FasterXML / jackson-dataformat-xml

Extension for Jackson JSON processor that adds support for serializing POJOs as XML (and deserializing from XML) as an alternative to JSON
Apache License 2.0
567 stars 221 forks source link

`@JacksonXmlText` does not work when paired with `@JsonRawValue` #545

Closed dudleycodes closed 2 years ago

dudleycodes commented 2 years ago

I apologize if there's a similar issue already opened - I didn't find anything when searching.

Describe the bug When a field has both the @JsonRawValue and the @JacksonXmlText annotations, the @JacksonXlmText annotation has no effect.

Version information com.fasterxml.jackson.core:jackson-annotations:2.13.3 com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.3

To Reproduce

@JacksonXmlRootElement(localName = "test-pojo")
public class TestPojo {
     @JacksonXmlProperty(isAttribute = true)
     String id;

     @JacksonXmlText
     @JsonRawValue
     String value;
}

//....

TestPojo sut = new TestPojo();
sut.id = "123";
sut.value = "<a>A</a><b someAttribute=\"B\">B</b>";

Actual output:

<test-pojo>
    <id>123</id>
     <value>
         <a>A</a>
         <b someAttribute="B">B</b>
     </value>
</test-pojo>

Expected output:

<test-pojo>
    <id>123</id>
    <a>A</a><b someAttribute="B">B</b>
</test-pojo>

Additional context

cowtowncoder commented 2 years ago

Moved to the right repository.

cowtowncoder commented 2 years ago

Thank you for reporting this, @dudleycodes and thank you @yawkat for fixing it so quickly! It will be in 2.14.0 (hoping to get first release candidate out within 2 weeks).