polymorphicDefaultSerializer

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

Adds a default serializers provider associated with the given baseClass to the resulting module. defaultSerializerProvider is invoked when no polymorphic serializers for value in the scope of baseClass were found.

Default serializers provider affects only serialization process. To affect deserialization process, use SerializersModuleBuilder.polymorphicDefaultDeserializer.

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