# ktor

Narek Mailian

02/28/2020, 11:29 AM
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)


03/27/2020, 3:34 PM
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!

Lars Toft Jacobsen

09/02/2021, 9:28 AM
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.