polymorphicDefaultSerializer

abstract fun <Base : Any> polymorphicDefaultSerializer(baseClass: KClass<Base>, defaultSerializerProvider: (value: Base) -> SerializationStrategy<Base>?)(source)

Accept a default serializer provider, associated with the baseClass for polymorphic serialization. defaultSerializerProvider is invoked when no polymorphic serializers for value in the scope of baseClass were found.

Default serializers provider affects only serialization process. Deserializers are accepted in the SerializersModuleCollector.polymorphicDefaultDeserializer method.

defaultSerializerProvider can be stateful and lookup a serializer for the missing type dynamically.