Hi! I'm trying to serialize a list of polymorphic ...
# ktor
n
Hi! I'm trying to serialize a list of polymorphic objects, but get the error "Serializing collections of different element types is not yet supported". Is there any workaround one can use? (besides wrapping everything in a serializable data class with a list)
t
Good day. I just ran into the same issue. I just want to set up a simple JSON body that can easily change without having to design a whole data class around it. Something like:
Copy code
body = mapOf("name" to name, "staffId" to auth.staffId)
The message includes the text
Copy code
is not yet supported
which makes it sound like it on the roadmap. Anybody have a link to a github or kotlin tracker issue for this? Thank you!
l
I think it’s possible using sealed class polymorphism
This would work
It is also be possible to register a polymorphic serializer for a type and its subtypes in the serializers module.