I try to write xml/json parser using Jackson. I use jackson-dataformat-xml that supports XML. I need to extract content of one of XML elements as a raw String and put it as it is into a POJO.
<rootElement>
<elementNumberOne>...</elementNumberOne>
<rawElement>rawElementContent<rawElement>
</rootElement>
rawElementContent can be a String or XML structure. Despite what is inside rawElement, the goal is to extract it as a raw value.
I tried to use @JsoneDeserialize and custom Deserializer, but I cannot get the orginial raw xml out of it. The only thing I achieved is to use XmlMapper inside of custom deserializer and use:
mapper.writeValueAsString(jsonNode);
However it's a workaround not a solution (getting Xml to Json and do the opposite way again).
Do you know a better way? Or it's not possible with Jackson?