agta1991
01/18/2020, 7:06 PMUnknownFieldException: Unknown field for index -2
I'm getting this when I try to use Mapper.unmap(serializer, map) call. I made a minimal reproduction code snipet.agta1991
01/18/2020, 7:06 PMimport kotlinx.serialization.Mapper
import kotlinx.serialization.Serializable
import kotlin.test.Test
import kotlin.test.assertTrue
class TestUnknownFieldException {
@Test
fun `Unknown field repro`() {
val input = mapOf(
"key" to "randomKey",
"value" to 12.345
)
val output = Mapper.unmap(KeyValueData.serializer(), input)
assertTrue { output.key == "randomKey" && output.value == 12.345 }
}
@Serializable
data class KeyValueData(
val key: String,
val value: Double
)
}
agta1991
01/18/2020, 7:07 PMrusshwolf
01/19/2020, 12:52 AMagta1991
01/19/2020, 8:33 PMrusshwolf
01/19/2020, 8:46 PMTaggedDecoder
which Mapper
calls into internally returns READ_ALL
from decodeElementIndex()
, and that constant isn’t supported on native. But you could manually handle item indexes yourself and get something similar working on nativeagta1991
01/19/2020, 10:54 PM