kotlinx.serialization v1.3.2 Release Notes

Release Date: 2021-12-23 // about 1 month 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)

Previous changes from v1.3.1

  • ๐Ÿ›  This release mainly contains bugfixes for 1.3.0 and provides new experimental Json.decodeToSequence function.

    ๐Ÿ‘Œ Improvements

    • Provide decodeToSequence to read multiple objects from stream lazily (#1691)

    ๐Ÿ›  Bugfixes

    • Correctly handle buffer boundaries while decoding escape sequences from json stream (#1706)
    • Properly skip unknown keys for objects and structures with zero properties (#1720)
    • Fix merging for maplikeSerializer when the map is not empty (by using the actual size * 2). (#1712) (thanks to pdvrieze)
    • Fix lookup of primitive array serializers by Java type token (#1708)