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
Describe the bug
When I tried Serializing interfaces example from docs but im getting On Kotlin/Native explicitly declared serializer should be used for interfaces and enums without @Serializable annotation To Reproduce
Just run the example code from the docs.
Please note that this example works only on JVM because of serializer function restrictions.
For JS and Native, explicit serializer should be used: format.encodeToString(PolymorphicSerializer(Project::class), data)
You can keep track of this issue here.
Describe the bug
When I tried Serializing interfaces example from docs but im getting
On Kotlin/Native explicitly declared serializer should be used for interfaces and enums without @Serializable annotation
To Reproduce
Just run the example code from the docs.
`import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.modules.*
val module = SerializersModule {
polymorphic(Project::class) {
subclass(OwnedProject::class)
}
}
val format = Json { serializersModule = module }
interface Project {
val name: String
}
@serializable
@SerialName("owned")
class OwnedProject(override val name: String, val owner: String) : Project
fun main() {
val data: Project = OwnedProject("kotlinx.coroutines", "kotlin")
println(format.encodeToString(data))
} `
Expected behavior
Environment
The text was updated successfully, but these errors were encountered: