growse
09/04/2023, 11:19 AMJsonTransformingSerializer
with a subclass, in that specifying the serializer in the mapper module doesn't seem to work. If I have:
object JsonTransforming : JsonTransformingSerializer<MessageConfiguration>(
MessageConfiguration.serializer()
) {...}
and set up a mapper as
Json {
classDiscriminator = "_type"
serializersModule = SerializersModule {
polymorphic(MessageBase::class, MessageConfiguration::class, JsonTransforming)
}
}
Then calling decodeFromString
only works properly if I pass in the serialization strategy explicitly.
decodeFromString<MessageBase>(JsonTransforming, input) // This works
decodeFromString<MessageBase>(input) // This doesn't run the transformer
My expectation is that specifying the polymorphic
bit in the serializersModule
would be sufficient for the deserializer to apply the transformer when it's deserializing a MessageConfiguration
, but it seems not. What am I doing wrong?