fun default(defaultSerializerProvider: (className: String?) -> DeserializationStrategy<out Base>?)

Adds a default deserializers provider associated with the given baseClass to the resulting module. defaultSerializerProvider is invoked when no polymorphic serializers associated with the className were found. className could be null for formats that support nullable class discriminators (currently only Json with JsonBuilder.useArrayPolymorphism set to false)

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

defaultSerializerProvider is named as such for backwards compatibility reasons; it provides deserializers.

Typically, if the class is not registered in advance, it is not possible to know the structure of the unknown type and have a precise serializer, so the default serializer has limited capabilities. To have a structural access to the unknown data, it is recommended to use JsonTransformingSerializer or JsonContentPolymorphicSerializer classes.

Default deserializers provider affects only deserialization process. To affect serialization process, use SerializersModuleBuilder.polymorphicDefaultSerializer.

See also