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 of Yaml):

    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.