Java - Jackson - How to NOT unescape < to < character automatically when deserializing? #253
-
I have a simple XML containing escaped string for
However, no matter what I tried, Jackson automatically unescape
I hope Jackson has a simple annotation for that to keep read value for key in NOTE: I don't want |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
|
Beta Was this translation helpful? Give feedback.
-
I wonder if you may have misunderstood role of CDATA marker in XML -- it is something that helps embed content that contains entities like One problem is that I do not find "tests" where the idea is to print out things and ask us to "have a look". to be useful: it is very difficult to get an idea of what exactly is requested. So I understand the high-level wish to process content as For what it is worth, I would recommend looking at doing something like:
and modifying resulting |
Beta Was this translation helpful? Give feedback.
My problem is that I am not sure I understand the request. But if I am right, you'd want to somehow disable XML parsing of content/sub-tree -- there is no way to do that. XML parsers do not really expose raw underlying undecoded content; they must parse documents. There's no way to get around that.
So it's not a question of annotations, it's that Stax XML parsers will always produce element/tag
value1
, CDATA for white space, element/tagrandomXML
and so on.So if that is the request there is nothing we can do, unfortunately.
On output side, however, there is an annotation
@JsonRawValue
, which can be used to inject pre-encoded content direclty into output stream. So if you had content know…