Deserializing @JacksonXmlText
See original GitHub issueWhilst there is no problem serializing a field annotated with @JacksonXmlText
, deserialization always chokes up. For example (in Scala, but should be clear enough):
case class Phone (
@JacksonXmlProperty(isAttribute = true, localName = "type") phoneType: String,
@JacksonXmlText phoneNumber: String
)
Serializes Phone("cell","000-000-0000")
into <phone type="cell">000-000-0000</phone>
, but deserializing the same thing will fail with
JsonMappingException: Could not find creator property with name ''
Is there a reason this can’t/shouldn’t be supported, at least in restricted situations like the above? It seems like this falls under the “XML written using this module must be readable using module as well”.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Jackson xml module: deserializing immutable type with a ...
Jackson xml module: deserializing immutable type with a @JacksonXmlText property ... I want to serialize an immutable type both as json and as...
Read more >JacksonXmlText (Jackson-dataformat-XML 2.1.1 API)
It will result in value of the property be serialized without element wrapper, as long as there are no element-wrapped other properties (attribute-valued ......
Read more >Solving the XML Problem with Jackson - Stackify
Next, let's have a look at the @JacksonXmlText annotation. ... The opposite of this is also possible – deserializing a Java bean from...
Read more >[jackson-user] XML Deserialization of @JacksonXmlText in Scala ...
Hi -- I am wondering if anyone has experienced the following issue with XML deserialization to Scala case classes annotated with @JacksonXmlText:
Read more >XML Serialization and Deserialization with Jackson - Baeldung
This short tutorial shows how the Jackson library can be used to serialize Java object to XML and deserialize them back to objects....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My current workaround is to use a custom deserializer:
Actually, forget about it. My problem is related to Kotlin data classes. Works fine with normal classes. Seems to be a known issue in jackson-module-kotlin: https://github.com/FasterXML/jackson-module-kotlin/issues/138