-
-
Notifications
You must be signed in to change notification settings - Fork 230
Closed
Milestone
Description
There is an issue with deserilalizing collecions when one of the element contains xsi:nil
attribuite and the default use wrapper is set to false.
Code for reproducing the issue:
fun main() {
xmlMapper.readValue<Root>(xml)
}
val xmlMapper = XmlMapper()
.setDefaultUseWrapper(false)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.registerKotlinModule()
.registerModule(JaxbAnnotationModule()) as XmlMapper
private const val xml = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root>
<Item>
<One xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">one</One>
<Two>two</Two>
</Item>
<Item>
<One>one1</One>
<Two>two2</Two>
</Item>
</Root>"""
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Root")
class Root {
@XmlElement(name = "Item")
lateinit var items: List<Item>
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Item")
class Item {
@XmlElement(name = "One")
lateinit var one: SubItem
@XmlElement(name = "Two")
lateinit var two: SubItem
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SubItem")
class SubItem {
@XmlValue
lateinit var value: String
}
This code works in 2.9.10, but after upgrading to the 2.10.0 the code returns the exception:
Exception in thread "main" com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `maven.Item` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('two')
Metadata
Metadata
Assignees
Labels
No labels