registerSerializer

fun <T : Any> registerSerializer(klass: KClass<T>, serializer: TypeSerializer<T>)

Registers a custom TypeSerializer for the given type klass.

Custom serializers allow non-standard types to be serialized to and deserialized from YAML. Registered serializers take precedence over default data class serialization.

Example:

YamlConfigManager.registerSerializer(Duration::class, DurationSerializer)

Since

1.0

Parameters

T

The type to register a serializer for.

klass

The KClass of the type.

serializer

The TypeSerializer implementation.

See also


inline fun <T : Any> registerSerializer(serializer: TypeSerializer<T>)

Registers a custom TypeSerializer for the reified type T.

This is a convenience overload that infers the KClass from the reified type parameter.

Example:

YamlConfigManager.registerSerializer<Duration>(DurationSerializer)

Since

1.0

Parameters

T

The type to register a serializer for.

serializer

The TypeSerializer implementation.

See also