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:

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 @Transient

Since

1.0

See also

Functions

Link copied to clipboard
fun <T : Any> serialize(instance: T, registry: SerializerRegistry): Map<String, Any?>

Serializes a configuration instance into a map of property names to values.