kotlinx.serialization v1.3.3 Release Notes

Release Date: 2022-05-11 // 5 months ago
  • ๐Ÿ›  This release contains support for Protocol Buffers packed fields, as well as several bugfixes. 0๏ธโƒฃ It uses Kotlin 1.6.21 by default.

    Protobuf packed fields

    ๐Ÿ“„ It is now possible to encode and decode Kotlin classes to/from Protobuf messages with packed repeated fields. To mark the field as packed, use @ProtoPacked annotation on it. Note it affects only List and primitive collection such as IntArray types. 0๏ธโƒฃ With this feature, it is now possible to decode Proto3 messages, where all repeated fields are packed by default. ๐Ÿ‘ Protobuf schema generator also supports new @ProtoPacked annotation.

    Many thanks to Paul de Vrieze for his valuable contribution!

    Other improvements & small features

    • Incorporate JsonPath into exception messages (#1841)
    • Mark block in corresponding encodeStructure/decodeStructure extensions as crossinline to reduce amount of bytecode (#1917)
    • Support serialization of compile-time Collection<E> properties that are not lists at the runtime (#1821)
    • Best-effort kotlin reflect avoidance in serializer(Type) (#1819)

    ๐Ÿ›  Bugfixes

    • Iterate over element indices in ObjectSerializer in order to let the format skip unknown keys (#1916)
    • Correctly support registering both default polymorphic serializer & deserializer (#1849)
    • Make error message for captured generic type parameters much more straightforward (#1863)

Previous changes from v1.3.2

  • ๐Ÿ›  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)