Yaml Reader
object YamlReader
Thin wrapper around SnakeYAML that reads YAML content into a Map<String, Any?> suitable for consumption by the Deserializer.
SnakeYAML automatically resolves YAML scalars to their natural JVM types (Int, Double, Boolean, String, etc.) and nested mappings to LinkedHashMap instances. This object re-uses a single Yaml parser instance, which is safe because SnakeYAML parsers are stateless after construction.
Usage from a file:
val map = YamlReader.read(File("config.yml"))
val config = deserializer.deserialize(MyConfig::class, map, errors)Content copied to clipboard
Usage from a raw string (useful in tests):
val yaml = """
server:
port: 8080
""".trimIndent()
val map = YamlReader.readString(yaml)Content copied to clipboard
Since
1.0