You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Serializable
@SerialName("test-b")
data class TestB(val data: Boolean)
@Test
fun parse() {
val xml = "<test-a data=\"true\"></test-a>"
val testB = XML.decodeFromString(TestB.serializer(), xml)
println(testB)
}
will result in an error:
nl.adaptivity.xmlutil.XmlException: local name test-a does not match expected "test-b"
at nl.adaptivity.xmlutil.XmlReader$DefaultImpls.require(XmlReader.kt:78)
at nl.adaptivity.xmlutil.XmlBufferedReaderBase.require(XmlBufferedReaderBase.kt:27)
at nl.adaptivity.xmlutil.XmlReader$DefaultImpls.require(XmlReader.kt:84)
at nl.adaptivity.xmlutil.XmlBufferedReaderBase.require(XmlBufferedReaderBase.kt:27)
at nl.adaptivity.xmlutil.serialization.XmlDecoderBase$TagDecoder.endStructure(XMLDecoder.kt:849)
at com.jeffpdavidson.kotwords.model.CrosswordTest$TestB$$serializer.deserialize(CrosswordTest.kt:18)
at com.jeffpdavidson.kotwords.model.CrosswordTest$TestB$$serializer.deserialize(CrosswordTest.kt:18)
at nl.adaptivity.xmlutil.serialization.XmlDecoderBase$XmlDecoder.decodeSerializableValue(XMLDecoder.kt:236)
at nl.adaptivity.xmlutil.serialization.XML.decodeFromReader(XML.kt:414)
at nl.adaptivity.xmlutil.serialization.XML.decodeFromReader$default(XML.kt:385)
at nl.adaptivity.xmlutil.serialization.XML.decodeFromString(XML.kt:351)
at nl.adaptivity.xmlutil.serialization.XML$Companion.decodeFromString(XML.kt:783)
This makes sense to me, and is long-standing behavior - the tag specified in @SerialName doesn't match the tag in the XML.
However, in 0.86.1 (or 0.86.2), parsing succeeds as TestB(data=true).
Is it expected that parsing should work even if the root tag is wrong? I looked at the 0.86.1 release notes and didn't see anything that obviously corresponded to such a behavior change.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
In 0.86.0, the following code:
will result in an error:
This makes sense to me, and is long-standing behavior - the tag specified in
@SerialNamedoesn't match the tag in the XML.However, in 0.86.1 (or 0.86.2), parsing succeeds as
TestB(data=true).Is it expected that parsing should work even if the root tag is wrong? I looked at the 0.86.1 release notes and didn't see anything that obviously corresponded to such a behavior change.
All reactions