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
import com.akuleshov7.ktoml.Toml
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.serializer
@Serializable
data class Foo(val x: List<Bar>)
@Serializable
data class Bar(val v: Int)
fun main(){
val foo = Foo(arrayListOf( Bar(42)))
val s = Toml().encodeToString(foo)
println(s)
val fooDeserialized = Toml().decodeFromString<Foo>(serializer(), s)
}
So when i run this, it produce next toml:
[[x]]
v = 42
And then, decoding throws error:
Exception in thread "main" com.akuleshov7.ktoml.exceptions.InternalDecodingException: Incorrect decoding state in the beginStructure() with [[x]] ([[x]])[x] It's an internal error - you can do nothing with it, please report it to https://github.com/akuleshov7/ktoml/
at com.akuleshov7.ktoml.decoders.TomlMainDecoder.iterateOverStructure(TomlMainDecoder.kt:246)
at com.akuleshov7.ktoml.decoders.TomlMainDecoder.beginStructure(TomlMainDecoder.kt:212)
at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:29)
at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
at kotlinx.serialization.encoding.Decoder$DefaultImpls.decodeSerializableValue(Decoding.kt:257)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:16)
at com.akuleshov7.ktoml.decoders.TomlAbstractDecoder.decodeSerializableValue(TomlAbstractDecoder.kt:96)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
at Foo$$serializer.deserialize(tomlProb.kt:6)
at Foo$$serializer.deserialize(tomlProb.kt:6)
at kotlinx.serialization.encoding.Decoder$DefaultImpls.decodeSerializableValue(Decoding.kt:257)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:16)
at com.akuleshov7.ktoml.decoders.TomlAbstractDecoder.decodeSerializableValue(TomlAbstractDecoder.kt:96)
at com.akuleshov7.ktoml.decoders.TomlMainDecoder$Companion.decode(TomlMainDecoder.kt:276)
at com.akuleshov7.ktoml.Toml.decodeFromString(Toml.kt:47)
at TomlProbKt.main(tomlProb.kt:18)
at TomlProbKt.main(tomlProb.kt)
The text was updated successfully, but these errors were encountered:
Hello! Thank you for your report.
Thing that you are trying to decode looks to be not a simple array, it is an array of tables. Which is not supported.
Please note that primitive arrays/lists are actually supported:
I have the next code:
So when i run this, it produce next toml:
And then, decoding throws error:
The text was updated successfully, but these errors were encountered: