Hi! I'm trying to use this to serialize messages t...
# serialization
j
Hi! I'm trying to use this to serialize messages to JSON -- I have a bunch of polymorphic definitions (see here: https://gist.github.com/jdkula/781c0edf83943df5e6dc9293f487029e) but I'm getting this error:
java.lang.IllegalArgumentException: Can't locate polymorphic serializer definition
(full stack trace: https://gist.github.com/jdkula/511b45a5de8224775418a39c23199d84) I'm compiling to Javascript from a common module. I'm using Kotlin 1.2.30.
j
I don't think so -- I'm not using a map, nor any other type with generics.
h
Does it help if you remove
@Serializable
from the base classes?
What I did in a somewhat similar situation was to have a custom serializer on the super class which decides which sub class to serialize to, and just remove
@Serializable
on the sub classes. In the custom serializer I used
input.read(Data::class.serializer())
where
Data
is a data class with all possible fields
j
Interesting... I'll try that. Thanks!