Serializer
object Serializer
Converts typed configuration objects into serialized map representations suitable for YAML output.
The serializer walks the primary constructor parameters of data classes in declaration order, producing a LinkedHashMap that preserves field ordering. Properties annotated with @Transient are excluded from output.
Supported value types:
Enums: serialized by their Enum.name
SecretString: serialized by exposing the underlying value
Custom types: dispatched to SerializerRegistry if a TypeSerializer is registered
Nested data classes: recursively serialized
All other types: converted via Any.toString
Example:
data class ServerConfig(
val host: String = "localhost",
val port: Int = 8080,
@Transient val runtimeOnly: String = "ignored"
)
val config = ServerConfig()
val map = Serializer.serialize(config, registry)
// map = {"host" -> "localhost", "port" -> 8080}
// Note: "runtimeOnly" is excluded because of @TransientContent copied to clipboard
Since
1.0