-
Notifications
You must be signed in to change notification settings - Fork 43
Deserialization issues with 0.90.2+ #254
Copy link
Copy link
Closed
Labels
cantfixThis issue cannot be resolved at this point because of limitations in external libraries.This issue cannot be resolved at this point because of limitations in external libraries.
Description
This problem occurs with 0.90.2 and 0.90.3. See the following example:
class Test {
@Serializable
@SerialName("element")
data class Element(
@XmlElement(true)
val a: String
)
@Serializable
@SerialName("element")
data class OtherElement(
@XmlElement(true)
val b: String
)
@Serializable
data class Parent(
val element: Element,
)
@Serializable
data class OtherParent(
val element: OtherElement,
)
@Serializable
data class Root(
val parent: Parent,
val otherParent: OtherParent,
)
@Test
fun `xml version 0_9_x test`() {
val xml = XML {
indent = 4
}
val root = Root(
parent = Parent(Element("element")),
otherParent = OtherParent(OtherElement("element")),
)
val serialized = xml.encodeToString(root)
println(serialized)
val deserialized: Root = XML.decodeFromString(serialized)
assertEquals(root, deserialized)
}
}This will print the following XML:
<Root>
<Parent>
<element>
<a>element</a>
</element>
</Parent>
<OtherParent>
<element>
<a>element</a>
</element>
</OtherParent>
</Root>Note how in OtherParent/element the tag is <a>, even though it should be <b>.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
cantfixThis issue cannot be resolved at this point because of limitations in external libraries.This issue cannot be resolved at this point because of limitations in external libraries.