Skip to content

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

Closed
@dudleycodes

Description

@dudleycodes

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

  • I tried cheating the system, by included a @JsonProperty("") annotation on the value field, it had no effect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions