kotlinx.serialization v1.3.2 Release Notes

Release Date: 2021-12-23 // over 2 years ago
  • 🛠 This release contains several features and bugfixes for core API as well as for HOCON format. 0️⃣ It uses Kotlin 1.6.10 by default.

    Serializing objects to HOCON

    It's now possible to encode Kotlin objects to Config values with new Hocon.encodeToConfig function. This feature may help edit existing configs inside Kotlin program or generate new ones.

    Big thanks to Osip Fatkullin for implementing this.

    0️⃣ Polymorphic default serializers

    🏗 As of now, polymorphicDefault clause inside SerializersModule { } builder specifies a fallback serializer to be used only during deserialization process. A new function has been introduced to allow setting 0️⃣ fallback serializer for serialization: polymorphicDefaultSerializer. This function should ease serializing vast hierarchies of third-party or Java classes.

    0️⃣ Note that there are two new experimental functions, polymorphicDefaultSerializer and polymorphicDefaultDeserializer. 🚀 To avoid naming confusion, we are going to deprecate polymorphicDefault in favor of polymorphicDefaultDeserializer in the next minor release (1.4.0).

    💻 Credit for the PR goes to our contributor Joseph Burton.

    Other improvements

    • HOCON: parse strings into integers and booleans if possible (#1795) (thanks to tobiaslieber)
    • Add an encodeCollection extensions (#1749) (thanks to Nicklas Ansman Giertz)

    🛠 Bugfixes

    • Properly handle top-level value classes in encodeToJsonElement (#1777)
    • Fix incorrect handling of object end when JsonTreeReader (JsonElement) is used with decodeToSequence (#1782)