Type Serializer
Core interface for converting configuration values between their typed representation and a raw storage form.
Implement this interface to support custom types in KConfig. Every implementation must be able to round-trip: calling deserialize on the output of serialize must produce an equivalent value.
Example -- a custom serializer for java.time.Instant:
object InstantSerializer : TypeSerializer<Instant> {
override fun serialize(value: Instant): Any = value.toString()
override fun deserialize(raw: Any): Instant = Instant.parse(raw.toString())
}
// Register it:
registry.register(Instant::class, InstantSerializer)Content copied to clipboard
Since
1.0
Parameters
T
The typed value this serializer handles.