I'm getting a weird runtime error while serializin...
# serialization
v
I'm getting a weird runtime error while serializing a class containing a
val items: ImmutableList<Item>
Copy code
kotlinx.serialization.SerializationException: Class 'SmallPersistentVector' is not registered for polymorphic serialization in the scope of 'ImmutableList'.
Mark the base class as 'sealed' or register the serializer explicitly.
This has been mentioned in #android before in this message: https://kotlinlang.slack.com/archives/C0B8M7BUY/p1661349374174729 but the linked docs don't really seem to help. The class I am trying to serialize is a data class, and the class Item is also a data class. Any ideas what could be causing this? I am using org.jetbrains.kotlinxkotlinx serialization json1.4.1 and org.jetbrains.kotlinxkotlinx collections immutable0.3.5
If anyone stumbles upon this later on, it's because kotlinx.collections.immutable doesn't support serialization yet. You can write your own, but it's not possible if you use kapt in the same package... https://github.com/Kotlin/kotlinx.serialization/issues/685 https://youtrack.jetbrains.com/issue/KT-30346
the list serializer works even if the implementation is immutable/persistentlist
106 Views