kaml v0.18.0 Release Notes
Release Date: 2020-07-12 // almost 4 years ago-
What's changed
๐ New : kaml now supports working with polymorphic types where the type is specified as a
type
property in YAML (#11 - thanks to @gps for the suggestion).๐ This means that there are now two styles available for working with polymorphic types (set
YamlConfiguration.polymorphismStyle
when creating an instance ofYaml
):using YAML tags to specify the type:
servers: - !\<frontend\>hostname: a.mycompany.com - !\<backend\>database: db-1
using a
type
property to specify the type:servers: - type: frontendhostname: a.mycompany.com - type: backenddatabase: db-1
The fragments above could be generated with:
@Serializablesealed class Server { @SerialName("frontend") @Serializabledata class Frontend(val hostname: String) @SerialName("backend") @Serializabledata class Backend(val database: String) }@Serializabledata class Config(val servers: List\<Server\>)val config = Config(listOf( Frontend("a.mycompany.com"), Backend("db-1") ))val result = Yaml.default.stringify(Config.serializer(), config)println(result)
โก๏ธ Updated : kaml is now built against Kotlin 1.3.72.
๐ Changed : clearer exceptions will now be thrown in the following cases:
- missing tag when deserializing a polymorphic type when using tags for polymorphic type information
- unknown polymorphic type in tag or
type
property - missing required property for object
โฌ๏ธ Upgrading
If you're using Gradle, reference kaml in your
dependencies
block like this:implementation("com.charleskorn.kaml:kaml:0.18.0")
๐ For other tools, refer to the Maven Central release page for more information.