Skip to content
CAI
Software that uses CAICheck a score

Kotlin/kotlinx.serialization

56.4

Adequate · 13 November 2026

26.1k

lines of production code

Kotlin

primary language

7

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Features

Add JSON serialization support for Kotlin/Wasm targets

The JSON serialization format now supports the Kotlin/Wasm target platform. This change introduces platform-specific implementations for internal JSON processing components, including schema caching, character array pooling, string writing, and map creation for caching, enabling the library to function correctly in WebAssembly environments.

formats/json/jsWasmMain · high confidence

Add Kotlin/Wasm support to kotlinx.serialization

This change introduces the core serialization infrastructure for the Kotlin/Wasm target. It adds platform-specific implementations for serializer caching, array handling, and built-in type serializers (including Duration, Instant, and Uuid). It also defines the \SerializableWith\ annotation and handles WASM-specific constraints, such as requiring explicit serializers for interfaces and enums without \@Serializable\.

core/wasmMain · high confidence

Add Okio integration for JSON serialization

The \kotlinx-serialization-json-okio\ module now provides functions to serialize and deserialize JSON directly to and from Okio's \BufferedSource\ and \BufferedSink\ types. This allows users to leverage Okio's I/O abstractions for efficient JSON parsing and generation, with support for multiple platforms including iOS, macOS, Linux, Windows, JavaScript, Wasm, and watchOS.

formats/json-okio · high confidence

Add Okio integration for JSON serialization

Users can now serialize and deserialize JSON directly to and from Okio's BufferedSink and BufferedSource types. This new integration provides extension functions on the Json class, including encodeToBufferedSink for writing, decodeFromBufferedSource for reading single objects, and decodeBufferedSourceToSequence for lazy, streaming deserialization of multiple elements.

formats/json-okio/commonMain/src/kotlinx/serialization/json/okio · high confidence

Add WASM support for Protobuf byte reversal

The Protobuf serialization format now supports the Kotlin/WASM target. This change introduces a platform-specific implementation for byte-reversal operations (Int and Long) required by the internal serialization logic, ensuring correct behavior on WebAssembly platforms.

formats/protobuf/wasmMain · high confidence

Add kotlinx-io integration for JSON I/O streams

The JSON I/O module now supports the kotlinx-io library, introducing new extension functions \encodeToSink\ and \decodeFromSource\ to serialize and deserialize JSON directly to and from \kotlinx.io\ \Sink\ and \Source\ objects. This integration includes optimized internal readers and writers (\KxIoReader\ and \KxIoJsonWriter\) that leverage specialized methods like \writeDecimalLong\ and efficient ASCII handling to improve performance for stream-based JSON operations.

formats/json-io/commonMain · high confidence

Add kotlinx-io integration for JSON serialization

The \formats/json-io\ module now integrates with the kotlinx-io library, exposing new extension functions on \kotlinx.serialization.json.Json\ to read from and write to kotlinx-io \Source\ and \Sink\ objects. Users can now use \decodeFromSource\, \encodeToSink\, and \decodeSourceToSequence\ to perform JSON serialization and deserialization directly against kotlinx-io streams, with API dumps and documentation packages updated to reflect these new capabilities.

formats/json-io · high confidence

Added internal stream support for Okio integration

The library now includes internal reader and writer implementations for Okio's BufferedSource and BufferedSink, enabling JSON serialization and deserialization directly to and from Okio streams. This addition supports efficient handling of ASCII data and correctly processes UTF-16 surrogate pairs for characters outside the Basic Multilingual Plane, forming the core infrastructure for the new Okio format support.

formats/json-okio/commonMain/src/kotlinx/serialization/json/okio/internal · high confidence

CBOR format adds COSE compliance features and configuration options

The CBOR serialization format now includes support for COSE (CBOR Object Signing and Encryption) compliance. Users can enable a preconfigured \Cbor.CoseCompliant\ instance that enforces definite length encoding, verifies all tags, and prefers CBOR labels over serial names. New configuration flags allow fine-grained control over tag encoding and verification (\encodeKeyTags\, \encodeValueTags\, \encodeObjectTags\, \verifyKeyTags\, \verifyValueTags\, \verifyObjectTags\), as well as \useDefiniteLengthEncoding\ and \preferCborLabelsOverNames\. Additionally, new annotations \@ByteString\, \@CborArray\, \@CborLabel\, \@ValueTags\, \@KeyTags\, and \@ObjectTags\ provide explicit control over CBOR major types and tagging semantics, while \CborEncoder\ and \CborDecoder\ interfaces expose the current configuration for custom serializers.

formats/cbor/commonMain/src/kotlinx/serialization/cbor · high confidence

Initial implementation of the HOCON serialization format

The HOCON format is now available for serializing and deserializing Kotlin data classes. This release introduces the core encoder and decoder infrastructure, enabling the conversion of standard types (such as strings, numbers, and collections) to and from HOCON configuration structures. It also adds built-in support for serializing Duration and ConfigMemorySize types, allowing users to work with time intervals and memory sizes using standard HOCON units (e.g., '2 m', '1 MiB').

formats/hocon/src/main · high confidence

Initial support for HOCON configuration serialization

Users can now serialize and deserialize Kotlin objects to and from HOCON (Human-Optimized Config Object Notation) format using the new Hocon SerialFormat. This feature allows converting Kotlin data classes into Lightbend's Config objects and vice versa, with specific support for encoding and decoding Duration values using standard HOCON time units (e.g., '2 m' for 120 seconds). The implementation also supports polymorphic serialization, configurable naming conventions, and contextual serializers for Java Duration and ConfigMemorySize types.

hocon · high confidence

Introduce Properties serialization format for Map-based encoding

The \kotlinx-serialization-properties\ module is now available, providing a \Properties\ serial format that enables encoding and decoding of data structures to and from \Map\<String, Any\>\ and \Map\<String, String\>\. This addition allows users to serialize objects into map-based representations, which is useful for configuration files, property lists, or interoperability with systems that use key-value pair structures. The format supports both standard and string-valued maps for both encoding and decoding operations.

formats/properties · high confidence

Introduce Properties serialization format for Map-based storage

Adds a new \Properties\ serialization format that transforms serializable class properties into a flat \Map\ with string keys and primitive values (or strings). This enables encoding and decoding objects to/from map structures, supporting nested objects via prefixed keys (e.g., \data.property1\) and lists via indexed keys (e.g., \l.0\). The format includes specific mappers for handling polymorphic types and provides both generic (\Map\<String, Any\>\) and string-only (\Map\<String, String\>\) output variants.

formats/properties/commonMain · high confidence

Introduce ProtoBufSchemaGenerator for automatic .proto file generation

Added a new experimental \ProtoBufSchemaGenerator\ that automatically generates Protocol Buffers version 2 schema text from Kotlin serializable classes. This tool allows users to derive \.proto\ definitions directly from their Kotlin \SerialDescriptor\ structures, handling message and enum generation, field numbering, and package configuration, thereby simplifying the creation of compatible protobuf schemas without manual writing.

formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/schema · high confidence

Introduce TreeJsonDecoder for JsonElement deserialization

Adds a new internal TreeJsonDecoder implementation that enables deserializing Kotlin objects directly from in-memory JsonElement trees (JsonObject, JsonArray, JsonPrimitive). This allows users to parse JSON strings into JsonElement structures first and then convert them to typed objects, providing a flexible intermediate representation for complex parsing scenarios.

json · high confidence

Introduce context-aware descriptor introspection for polymorphic and contextual serialization

Added the \capturedKClass\ extension property to \SerialDescriptor\ and corresponding \SerializersModule\ lookup functions (\getContextualDescriptor\, \getPolymorphicDescriptors\) to enable runtime introspection of the actual Kotlin class behind contextual or open polymorphic serialization. This allows schema introspection tools and applications to resolve the specific types involved in contextual or polymorphic serialization at runtime, rather than relying solely on static descriptor information.

core/commonMain/src/kotlinx/serialization/descriptors · high confidence

Introduction of Kotlinx Serialization JSON format core components

This change introduces the foundational classes and APIs for the JSON serialization format in kotlinx.serialization. It adds the main \Json\ entry point and its \JsonConfiguration\ for settings like \ignoreUnknownKeys\ and \prettyPrint\, along with DSL builders (\buildJsonObject\, \buildJsonArray\) for constructing JSON trees. The update also includes new annotations such as \@JsonNames\ for alternative property names, \@JsonIgnoreUnknownKeys\ for per-class unknown key handling, and \@JsonClassDiscriminator\ for polymorphic serialization, as well as the \JsonContentPolymorphicSerializer\ for content-based type resolution.

formats/json/commonMain/src/kotlinx/serialization/json · high confidence

New JSON configuration options and polymorphic modes

The JSON format now exposes new configuration capabilities through the public API, allowing users to control parsing and serialization behavior more granularly. Users can now configure the class discriminator mode for polymorphic serialization using the new ClassDiscriminatorMode enum (ALL\_JSON\_OBJECTS, NONE, POLYMORPHIC), enable case-insensitive enum decoding, allow trailing commas and comments in JSON input, and set a maximum nesting depth to prevent stack overflows. Additionally, the API introduces a DecodeSequenceMode enum for controlling how sequences are decoded (ARRAY\_WRAPPED, AUTO\_DETECT, WHITESPACE\_SEPARATED) and exposes the JsonConfiguration class for custom serializer integration.

formats/json · high confidence

New JVM stream integration and lazy sequence decoding

The JVM module now provides direct integration with Java I/O streams, adding \encodeToStream\ and \decodeFromStream\ functions to serialize and deserialize JSON directly to and from \OutputStream\ and \InputStream\ instances. Additionally, a new \decodeToSequence\ API allows users to lazily read multiple JSON objects from a stream as a \Sequence\, enabling efficient processing of large or infinite data sources without loading everything into memory at once.

formats/json/jvmMain/src/kotlinx/serialization/json · high confidence

New built-in serializers for Long as String and Instant components

The builtins module now includes LongAsStringSerializer, which encodes Long values as strings to ensure safe interoperability with clients that have limited number precision (such as JavaScript), and InstantComponentSerializer, which encodes kotlin.time.Instant as a structure containing epochSeconds and nanosecondsOfSecond fields.

core/commonMain/src/kotlinx/serialization/builtins · high confidence

New executable code examples for the serialization guide

The guide now includes a comprehensive set of runnable Kotlin code snippets (generated via Knit) covering basic serialization, built-in types, class configuration, and format-specific usage for JSON, CBOR, and ProtoBuf. These examples demonstrate practical usage of features such as \@Serializable\, \@SerialName\, \@EncodeDefault\, \@JsonIgnoreUnknownKeys\, \@JsonNames\, and custom encoder/decoder implementations, providing users with verified reference code for common serialization scenarios.

guide/example · high confidence

Support for JSON comments via new lexer implementations

The JSON lexer infrastructure has been refactored to introduce dedicated lexer classes that support parsing JSON with comments. New files \CommentLexers.kt\ and updated factory functions in \StringJsonLexer.kt\ and \BufferedJsonLexer.kt\ implement \StringJsonLexerWithComments\ and \BufferedJsonLexerWithComments\, which extend the base \AbstractJsonLexer\ to skip both single-line (\//\) and block (\/\* \*/\) comments during tokenization. This change enables the \allowComments\ configuration flag to function correctly by routing the parser through these comment-aware implementations when the flag is enabled, while maintaining performance for non-comment JSON by keeping the standard lexers separate.

formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer · high confidence

Support for dynamic JavaScript object serialization and deserialization

The Kotlin/JS JSON module now includes \Dynamics.kt\, which adds \decodeFromDynamic\ and \encodeToDynamic\ extension functions to the \Json\ class. This allows users to directly convert native JavaScript objects into Kotlin data structures and vice versa, verifying types during decoding. The implementation supports array-based polymorphism if enabled in the JSON configuration, handles top-level primitives, and imposes specific limitations on \Long\ values (capped at \abs(2^53-1)\ for precision) and Map keys (restricted to String, primitive, or enum types).

formats/json/jsMain/src/kotlinx/serialization/json · high confidence

Support for object-based serialization and deserialization of polymorphic types in JSON on JS platform

This change introduces new internal decoders and encoders (DynamicDecoders.kt and DynamicEncoders.kt) for the JS platform, enabling the serialization and deserialization of Kotlin data structures to and from plain JavaScript objects (dynamic types). The implementation supports polymorphic serialization using discriminators, handles explicit nulls configuration, and includes specific logic for coercing input values and managing enum names. This allows JS-specific code to interact with kotlinx.serialization using native JavaScript object structures rather than JSON strings.

formats/json/jsMain/src/kotlinx/serialization/json/internal · high confidence

Removals

Removal of legacy serialization runtime and format implementations

The legacy serialization runtime library, including the core \Serialization.kt\ definitions, built-in serializers, and format-specific implementations for JSON and CBOR, has been removed from this module. This change eliminates the deprecated serialization API and its associated code, aligning with the migration of the KotlinX serialization runtime to a separate project.

src/main · high confidence

Architecture

Add module-info.java for HOCON format module

The HOCON format module now includes a module-info.java descriptor, explicitly declaring its dependencies on the Kotlin standard library, kotlinx.serialization core, and typesafe.config, and exporting the kotlinx.serialization.hocon package. This change supports Java Platform Module System (JPMS) integration and helps prevent IDE issues related to module compilation.

formats/hocon/src/mainModule · high confidence

Behavioural changes

1 commit (0 fixes) modifying formats/protobuf/commonTest, rules-integration-tests

A change to existing behaviour in formats/protobuf/commonTest, rules-integration-tests — 1 commit, 4 files: “Addressed various compilation warnings (\#3255)” (refs \#3255). Also in this area: Added integration tests for R8 code shrinking and obfuscation.

rules-integration-tests · medium confidence · unverified

Add internal stream abstractions for CBOR serialization

The CBOR format module now includes internal \ByteArrayInput\ and \ByteArrayOutput\ classes to handle byte array reading and writing. These new internal utilities provide the underlying stream mechanics required for CBOR encoding and decoding, supporting the broader CBOR feature additions and API stabilization efforts.

cbor · high confidence

Added Java 9+ module descriptors for serialization modules

This change introduces explicit \module-info.java\ files for the core serialization library and its format-specific modules (CBOR, JSON, Properties, and Protobuf). By defining these Java Platform Module System (JPMS) modules, the library now properly declares its package exports and dependencies (such as \kotlin.stdlib\ and \kotlinx.serialization.core\), which resolves IDE compatibility issues and ensures correct module path resolution for users building Java 9+ applications.

(repo-wide) · high confidence

Added platform-specific byte reversal implementations for Protobuf

The Protobuf serialization module now includes explicit implementations for reversing byte order on JS, JVM, and Native platforms. This ensures correct handling of integer and long byte sequences during serialization across all supported targets, replacing any previous platform-agnostic or missing logic with optimized, native-specific routines (e.g., using \Integer.reverseBytes\ on JVM and bitwise operations on JS/Native).

formats/protobuf/jsMain, formats/protobuf/jvmMain, formats/protobuf/nativeMain · high confidence

Build system now uses JetBrains cache redirector for Maven repositories

The build configuration now automatically redirects downloads from major public repositories (such as Maven Central, Gradle Plugins, Clojars, and Google's Android repositories) through JetBrains' cache-redirector service. This change is implemented via a new settings plugin that intercepts repository URL configurations in the build script and project repositories, aiming to improve build performance and reliability by leveraging a centralized caching layer.

build-settings-logic · high confidence

Build system restructured with new Gradle conventions and compiler options

The buildSrc module has been completely rewritten to use modern Gradle conventions and Kotlin DSL. This introduces a new CompilerOptions.kt file that centralizes default compiler arguments, including enabling the Unused Return Value checker and setting Java 8 compatibility. Native targets are now configured to run tests in release mode, and the build system respects overridden language versions when creating verifyModule tasks. Additionally, the build now includes conventions for JPMS modularity, Kover coverage verification, and cache redirectors for Yarn and NPM, while suppressing deprecation warnings for removed or deprecated native targets like watchosArm32 and apple x64.

buildSrc · high confidence

CBOR format API stabilization and COSE compliance support

The CBOR serialization format API has been stabilized, introducing a new \Cbor\ builder configuration that allows users to enable COSE-compliant encoding via the \CoseCompliant\ default instance. The API now exposes granular control over CBOR features, including options to ignore unknown keys, use definite length encoding, prefer CBOR labels over names, and verify or encode key, object, and value tags. Additionally, the \CborTag\ constants are now available for explicit tag handling, and the public API surface has been cleaned up to remove deprecated methods, ensuring binary compatibility for multiplatform targets.

formats/cbor · high confidence

CBOR format implementation refactored with improved error reporting and tag handling

The internal CBOR decoder and encoder have been restructured to support COSE compliance features, including explicit handling of CBOR labels, key/value tags, and object tags. Decoding errors now include specific tag information to aid debugging, and the decoder correctly skips structures when the ignoreUnknownKeys setting is enabled. Additionally, unsigned integer types are now encoded as positive integers, and byte string handling has been refined to support both explicit ByteString annotations and inline value classes.

formats/cbor/commonMain/src/kotlinx/serialization/cbor/internal · high confidence

Improved serializer caching stability and memory safety on JVM

The JVM serialization module now uses a new internal caching implementation in \Caching.kt\ that prevents class loader leaks by wrapping cached values in \SoftReference\ via a custom \ClassValue\-based cache, while falling back to \ConcurrentHashMap\ on platforms like Android where \ClassValue\ is unavailable. This change also fixes a memory leak caused by an incorrect \equals\ implementation in \KTypeWrapper\, ensuring that parametrized types from different class loaders are handled correctly and that cached serializers do not prevent garbage collection of unused class loaders.

core/jvmMain · high confidence

Integration tests now use Gradle 8.7 via the JetBrains cache redirector

The integration-test/gradle location has been updated to use Gradle 8.7, replacing previous versions. The Gradle wrapper properties now point to the JetBrains cache redirector (services.gradle.org) for downloading the distribution, which should improve download reliability and speed for the integration tests.

integration-test/gradle · high confidence

Internal JSON parsing and encoding engine refactored

The internal JSON parsing and encoding engine has been restructured into a new set of dedicated components to improve performance, maintainability, and error handling. This change introduces a new \JsonPath\ system for accurate error reporting, a \CharArrayPool\ for buffer reuse, and a \JsonTreeReader\ for converting JSON to \JsonElement\ trees. It also adds a \FormatLanguage\ annotation for IDE support, a \JsonSerializersModuleValidator\ to enforce polymorphic serialization rules at registration time, and new \InternalJsonWriter\/\InternalJsonReader\ interfaces to facilitate integration with external I/O libraries like Okio and kotlinx-io.

formats/json/commonMain/src/kotlinx/serialization/json/internal · high confidence

Internal serialization engine refactoring and new built-in type support

The internal serialization engine has been restructured with new files handling core serialization logic, including a new AbstractPolymorphicSerializer for multiplatform polymorphic types, dedicated serializers for kotlin.time.Instant, kotlin.time.Duration, and kotlin.uuid.Uuid, and improved collection and map descriptor handling. The codebase now supports serialization of kotlin.Nothing (throwing appropriate exceptions), implements stable hashCode/equals for descriptors, and introduces caching mechanisms for serial names and serializers to improve performance. Additionally, internal utilities for hex conversion, platform-specific serializer lookup, and missing field exception handling have been consolidated.

core/commonMain/src/kotlinx/serialization/internal · high confidence

Introduction of AbstractEncoder and AbstractDecoder base classes

The encoding module now provides AbstractEncoder and AbstractDecoder, which serve as skeleton implementations for Encoder and Decoder respectively. These classes simplify the creation of custom serialization formats by offering default implementations for primitive decoding and encoding methods that delegate to a generic decodeValue/encodeValue mechanism, as well as handling structure boundaries and element encoding checks via encodeElement. Additionally, the ChunkedDecoder interface is deprecated, indicating that chunk-based string decoding support is being phased out in subsequent releases.

core/commonMain/src/kotlinx/serialization/encoding · high confidence

JS platform serialization support and builtins initialization

The JS target now includes a dedicated internal platform implementation that initializes the builtins serializer map, explicitly adding support for kotlin.time.Instant and kotlin.uuid.Uuid serializers alongside standard primitives. This change also implements robust serializer lookup for the Nothing type and interfaces on JS, ensuring that serializer resolution does not fail with runtime errors for these edge cases.

core/jsMain/src/kotlinx/serialization/internal · high confidence

JVM-specific serializer resolution and builtins initialization

The library now includes a new JVM-specific platform implementation that handles serializer discovery via reflection, including support for named companion objects and improved handling of Java objects to prevent access errors. It also initializes the builtins map with standard primitive serializers and adds an annotation to suppress Android API compatibility warnings for JVM-only code.

core/jvmMain/src/kotlinx/serialization/internal · high confidence

Migrate documentation site configuration to kotlinlang.org

The documentation website configuration has been updated to support the migration to kotlinlang.org. This includes a new build profile configuration for the serialization product that enables browser-based edits directly from the documentation site, pointing to the repository's doc-restructuring-master branch, and disables automatic link summaries.

docs-website · high confidence

Native JSON internal implementation updates

This change introduces platform-specific implementations for the native target within the JSON serialization module. It adds a character array pooling mechanism (JsonLexerBufferPool) to optimize memory usage during input stream decoding, implements the FormatLanguage annotation for native builds, provides a StringJsonWriter for efficient string-based JSON output, and defines a native-compatible cache map creation function using HashMap.

formats/json/nativeMain/src/kotlinx/serialization/json/internal · high confidence

Native platform serializer initialization and caching implementation

The Kotlin/Native serialization runtime now includes a dedicated platform-specific implementation for initializing built-in serializers and managing serializer caches. This change introduces support for serializing \kotlin.time.Instant\, \kotlin.uuid.Uuid\, and \kotlin.time.Duration\ types on Native targets. It also implements a caching mechanism for serializer lookups to improve performance and updates the error messaging to provide specific guidance for Native users when serializers are not registered (e.g., requiring \@Serializable\ for enums or \PolymorphicSerializer\ for interfaces).

core/nativeMain · high confidence

Optimized JSON stream decoding with array pooling and Java 8 compatibility fixes

The internal JSON stream decoding logic has been rewritten to significantly improve performance and stability. A new array pooling system (ArrayPools) reuses CharArray and ByteArray instances to reduce garbage collection pressure during encoding and decoding. The CharsetReader and stream writers now use these pooled buffers and a hand-rolled UTF-8 transcoding path, which also resolves NoSuchMethodError issues on Java 8 by avoiding specific ByteBuffer API methods that were unavailable in that version. Additionally, a new ConcurrentHashMap-based cache is used on JVM to improve thread-safe caching performance.

formats/json/jvmMain/src/kotlinx/serialization/json/internal · high confidence

Optimized varint encoding and decoding in Protobuf format

The Protobuf serialization format now uses a new internal \ByteArrayInput\ and \ByteArrayOutput\ implementation that significantly optimizes varint reading and writing. This change introduces fast-path unrolled loops for single and two-byte varint values, reducing overhead during serialization and deserialization. Users will experience improved performance when encoding or decoding Protobuf data, particularly for messages containing many integer fields.

protobuf · high confidence

ProtoBuf format API stabilization and unknown field support

The ProtoBuf serialization format has undergone API stabilization, renaming core methods from dump/load to encodeToByteArray/decodeFromByteArray and encodeToHexString/decodeFromHexString for consistency with other formats. This update introduces support for preserving unknown fields during deserialization via the new ProtoUnknownFieldHolder class, allowing applications to retain data from newer schema versions. Additionally, new annotations (@ProtoNumber, @ProtoOneOf, @ProtoPacked, @ProtoType) and the ProtoIntegerType enum provide finer control over protobuf encoding details, while the ProtoBufSchemaGenerator enables automatic generation of .proto schema files from Kotlin serializable classes.

formats/protobuf/api · high confidence

ProtoBuf format rework with unknown field preservation and oneof support

The ProtoBuf serialization format has been restructured to introduce a builder-based configuration pattern (replacing direct instantiation) and add support for preserving unknown fields via the new ProtoUnknownFieldHolder class. The format now also supports protobuf oneof declarations through the ProtoOneOf annotation and allows explicit control over packed array encoding for collections using the ProtoPacked annotation. Additionally, the default behavior for encoding default values has changed, with encodeDefaults now defaulting to false, meaning properties with default values will be omitted from the serialized output unless explicitly enabled.

formats/protobuf/commonMain/src/kotlinx/serialization/protobuf · high confidence

ProtoBuf internal implementation refactored and stabilized

The internal implementation of the ProtoBuf format has been restructured to improve maintainability and support advanced features. This change introduces dedicated internal classes for handling packed arrays (PackedArrayEncoder/Decoder), oneof declarations, and unknown field preservation. It also adds validation to prohibit zero and negative field numbers, fixes encoding for Kotlin unsigned types and negative enums, and ensures empty packed collections are skipped during encoding. These updates refine how the library reads and writes binary data, enhancing compatibility with the Protocol Buffers specification.

formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/internal · high confidence

Refactored polymorphic module registration with separate default serializers and deserializers

The polymorphic module builder now distinguishes between default serializers (for serialization) and default deserializers (for deserialization), replacing the previous single 'default' method with explicit 'polymorphicDefaultSerializer' and 'polymorphicDefaultDeserializer' APIs. This change allows users to provide fallback handling for both directions independently, improving support for unknown types during both serialization and deserialization. The 'default' method is deprecated in favor of 'polymorphicDefaultDeserializer' to maintain backward compatibility while encouraging clearer intent. Additionally, the 'subclassesOfSealed' function is available to automatically register sealed class hierarchies, and the 'overwriteWith' operator enables merging modules with conflict resolution.

core/commonMain/src/kotlinx/serialization/modules · high confidence

Rename Serializers.kt to SerializersJs.kt for JS per-file compilation

The serialization module for the JS target has renamed its source file from Serializers.kt to SerializersJs.kt. This change supports JS per-file compilation requirements, ensuring that the file structure aligns with the platform-specific build configuration without altering the underlying SerializableWith annotation logic.

core/jsMain/src/kotlinx/serialization · high confidence

Serialization core library restructured into new package layout with stabilized annotations

The kotlinx.serialization core module has been reorganized, moving key components like annotations, serializers, and formats into the \core/commonMain/src/kotlinx/serialization\ directory. This change stabilizes several previously experimental annotations, including \@Serializable\, \@SerialName\, \@Required\, \@Transient\, and \@EncodeDefault\, removing the need for opt-in annotations in most standard use cases. The library also introduces new API level markers like \@ExperimentalSerializationApi\ and \@InternalSerializationApi\ to better manage stability guarantees, while retaining core interfaces such as \KSerializer\, \SerialFormat\, and polymorphic serializers like \PolymorphicSerializer\ and \SealedClassSerializer\ in this central location.

core/commonMain/src/kotlinx/serialization · high confidence

Stabilized HOCON serialization format with new encoder/decoder interfaces

The HOCON format support is now stabilized under the \kotlinx.serialization.hocon\ package, replacing the previous \ConfigParser\ naming. Users can now utilize the new \Hocon\ serial format along with dedicated \HoconEncoder\ and \HoconDecoder\ interfaces for serialization and deserialization. The API includes a builder for configuration options such as class discriminators and polymorphism handling, and provides built-in serializers for \ConfigMemorySize\ and \JavaDuration\ types.

formats/hocon · high confidence

Stabilized core serialization API and annotations

The \kotlinx-serialization-core\ module now exposes a stabilized public API surface, including the \@EncodeDefault\ annotation (with \ALWAYS\ and \NEVER\ modes) to control default value encoding, the \@SealedSerializationApi\ annotation for sealed class serialization features, and the \MissingFieldException\ class (now public) which includes a \serialName\ property for better debugging. The \SerialFormat\ interface now exposes \getSerializersModule()\, and built-in serializers for unsigned primitives (\UByte\, \UInt\, \ULong\, \UShort\) and their arrays are available in \BuiltinSerializersKt\. This change formalizes the core contract for serialization strategies, descriptors, and exceptions used across the library.

core/api · high confidence

Support for Pair, Triple, and Collection type resolution via Java Type tokens

The JVM serializer lookup for Java \Type\ tokens now explicitly resolves built-in serializers for \Pair\, \Triple\, and \Collection\ (treating them as \ArrayList\/\List\). This change ensures that generic classes using these types are correctly serialized without requiring explicit contextual registration, improving interoperability for JVM-centric libraries that rely on Java type tokens.

core/jvmMain/src/kotlinx/serialization · high confidence

Thread-local schema caching for Native platforms

The JSON serialization library now uses a thread-local map to store schema caches for custom JSON instances on Native platforms. This change ensures thread safety by preventing shared mutable state between workers, replacing the previous approach where each instance might have had its own cache member. The implementation uses weak references to avoid memory leaks when JSON instances are no longer in use, with periodic cleanup of dead references.

formats/json/nativeMain/src/kotlinx/serialization/json · high confidence

Updated ProGuard and R8 rules for kotlinx-serialization compatibility

The library now includes specific obfuscation rules to prevent runtime errors in Android environments using R8 full mode or ProGuard. These changes ensure that \INSTANCE\ fields and \serializer()\ functions for serializable objects are preserved, preventing \VerifyError\ and incorrect bytecode generation. Additionally, the rules maintain runtime annotations required for polymorphic serialization and suppress warnings related to \java.lang.ClassValue\ caching.

rules · high confidence

kotlinx.serialization 1.12.0-RC release notes and documentation update

The 1.12.0-RC release candidate introduces API stabilization for core components like \@KeepGeneratedSerializer\, \@SerialInfo\, \JsonNamingStrategy\, and \ContextualSerializer\, alongside performance enhancements for ASCII parsing and large string handling. It also brings significant improvements to exception handling by wrapping deserialization errors in \JsonException\, adds Protobuf support for unknown fields, and updates the library to be based on Kotlin 2.4.10.

(repo-wide) · high confidence

Test coverage

Added JS platform detection test utility; Added JS platform test infrastructure for Protobuf serialization; Added JS-specific tests for dynamic JSON serialization; Added JSON test resources for corner cases and spec compliance; Added JVM platform detection test utility; Added JVM test coverage for BigDecimal, Java collections, and serializer caching; Added JVM tests for JSON compatibility, chunked decoding, concurrency, and error handling; Added JVM tests for ProtoBuf serialization compatibility and behavior; Added JVM-specific CBOR test suite; Added JVM-specific serialization tests for contextual, inheritance, streaming, and type resolution; Added JVM-specific test utilities for serialization tests; Added Proto3 conformance tests for enums, maps, messages, oneofs, and repeated fields; Added automated tests for the Kotlin Serialization guide examples; Added comprehensive test coverage for JSON serializer components; Added comprehensive test coverage for serialization core behaviors; Added native platform detection test file; Added native platform tests for JSON serialization; Added platform detection test for Kotlin/Native; Added platform detection utilities for WASM support in tests; Added protobuf test schemas for proto2 and proto3; Added test coverage for HOCON serialization features; Added test infrastructure and utilities for JSON serialization; Added test infrastructure for compiler version checks and platform detection; Added test infrastructure for the WASM target; Added test suite for Protobuf schema generation; Added test utilities and data for CBOR serialization tests; Added test utilities for Protobuf serialization; Added tests for JSON I/O and Okio integration; Added tests for JSON escape marker validation; Added tests for JSON serialization edge cases and error handling; Added tests for Properties format serialization capabilities; Added tests for ProtoBuf serialization edge cases and validation; Added tests for Protobuf schema generation edge cases and validations; Added tests for built-in serializers and serial name collision handling; Added tests for contextual serialization of generic classes and module builder behavior; Added tests for inline classes and unsigned integer serialization; Added tests for sequential decoding behavior; Added tests for serialization schema descriptors and sealed interfaces; CBOR format tests migrated to new module structure; Expanded JVM-specific serialization test coverage; Expanded test coverage for JSON polymorphic serialization modes and structures; Expanded test coverage for JSON serialization behaviors; Integration test suite now covers Wasm (JS and WASI) targets; New JSON feature tests for comments, case-insensitive enums, naming strategies, and polymorphism; New benchmark suite for CBOR, JSON, and Moshi performance; Support for sealed interfaces and inline value classes in JSON serialization.

Dependencies

Gradle wrapper upgraded to version 8.7 with enhanced security and reliability

The project's Gradle wrapper has been updated from version 3.5 to 8.7. This upgrade includes a new distribution URL pointing to a JetBrains cache redirector for faster downloads, enables SHA-256 checksum validation for the Gradle distribution to ensure integrity, and adds a network timeout configuration. Users will benefit from the latest Gradle features, improved build performance, and stronger security guarantees during the download and verification process.

gradle · high confidence

Upgrade to Kotlin 2.4 and update build tooling dependencies

The project has upgraded its Kotlin compiler version to 2.4.10, as defined in the central version catalog (gradle/libs.versions.toml). This update is accompanied by upgrades to several build and testing dependencies, including JMH Core to 1.37, the Binary Compatibility Validator to 0.18.1, Dokka to 2.2.0-Beta, and the Gradle Shadow plugin to 8.3.9. The core runtime library now requires Kotlin 2.0.0-RC1 or later, and the integration tests have been configured to run native tests in release mode.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 56 → 56 (+0.2)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.

Lenses

  • Code Health 82 → 81 (-0.8)
  • Architecture 96 → 96 (-0.5)
  • Maturity 51 → 61 (+9.2)
  • Readiness 43 → 39 (-3.9)
  • Security 80 → 77 (-3.0)
  • Performance 86 → 91 (+4.9)

Resolved (9)

  • Ambiguous Overloading in Extension Functions: SerialFormatKt provides both explicit serializer-based hex methods and generic value-only hex methods. While the generic ones likely use context receivers or implicit serializers, having both encodeToHexString(serializer, value) and encodeToHexString(value) in the same scope can be confusing regarding which one is invoked in different contexts, especially if the generic ones rely on implicit resolution that might not be obvious to users.
  • Duplicated block (11–12 lines × 2) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/CommentLexers.kt)
  • Duplicated block (13 lines × 2) (formats/json-io/commonMain/src/kotlinx/serialization/json/io/internal/IoJsonStreams.kt)
  • Duplicated block (7 lines × 3) (core/jsMain/src/kotlinx/serialization/internal/Platform.kt)
  • Duplicated block (7 lines × 3) (core/jsMain/src/kotlinx/serialization/internal/Platform.kt)
  • Duplicated block (8 lines × 2) (formats/cbor/commonMain/src/kotlinx/serialization/cbor/internal/Streams.kt)
  • Off-boarding risk: anonymized user #1
  • Off-boarding risk: anonymized user #2
  • Redundant Interface Definition: BinaryFormat defines the exact same method signatures as ProtoBuf and Cbor directly. Since ProtoBuf and Cbor are concrete implementations that do not explicitly inherit from BinaryFormat in this surface (or if they do, the interface is redundant if it adds no new behavior), it creates a potential for confusion about whether these classes implement BinaryFormat. More critically, if they do not, the API surface is inconsistent in how it exposes binary serialization capabilities.

New (29)

  • Banned license: org.openjdk.jmh:jmh-core
  • Duplicated block (11–12 lines × 2) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/CommentLexers.kt)
  • Duplicated block (15 lines × 2) (formats/json-io/commonMain/src/kotlinx/serialization/json/io/internal/IoJsonStreams.kt)
  • Duplicated block (5 lines × 2) (formats/json-io/commonMain/src/kotlinx/serialization/json/io/internal/IoJsonStreams.kt)
  • Duplicated block (7 lines × 2) (formats/json/jvmMain/src/kotlinx/serialization/json/internal/JvmJsonStreams.kt)
  • Duplicated block (7 lines × 3) (core/jsMain/src/kotlinx/serialization/internal/Platform.kt)
  • Duplicated block (7 lines × 3) (core/jsMain/src/kotlinx/serialization/internal/Platform.kt)
  • Duplicated block (8 lines × 2) (formats/cbor/commonMain/src/kotlinx/serialization/cbor/internal/Streams.kt)
  • Duplicated block (8 lines × 3) (formats/json-io/commonMain/src/kotlinx/serialization/json/io/IoStreams.kt)
  • Edited copy of a member (11 corresponding lines) (formats/cbor/commonMain/src/kotlinx/serialization/cbor/internal/Decoder.kt)
  • Edited copy of a member (12 corresponding lines) (core/commonMain/src/kotlinx/serialization/internal/Enums.kt)
  • Edited copy of a member (12 corresponding lines) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/CommentLexers.kt)
  • Edited copy of a member (16 corresponding lines) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/BufferedJsonLexer.kt)
  • Edited copy of a member (16 corresponding lines) (formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/internal/ProtobufTaggedEncoder.kt)
  • Edited copy of a member (18 corresponding lines) (formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/schema/ProtoBufSchemaGenerator.kt)
  • Edited copy of a member (2 corresponding lines) (formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/internal/ProtobufDecoding.kt)
  • Edited copy of a member (21 corresponding lines) (formats/json/jvmMain/src/kotlinx/serialization/json/internal/JvmJsonStreams.kt)
  • Edited copy of a member (21 corresponding lines) (formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/internal/Streams.kt)
  • Edited copy of a member (25 corresponding lines) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/BufferedJsonLexer.kt)
  • Edited copy of a member (43 corresponding lines) (formats/json/jvmMain/src/kotlinx/serialization/json/internal/JvmJsonStreams.kt)
  • …and 9 more

Changes since last survey

  • 6 commits — 3 feature/other, 3 fixes

By area

  • (root) — 2 commits
  • formats/json — 2 commits
  • (repo) — 1 commit
  • formats/json-tests — 1 commit

Notable commits

  • fix: Revert "Add exception handling to decodeSerializableValue in Json decoders"
  • fix: Revert "Add exception handling to encodeSerializableValue in Json encoders"
  • fix: Revert "Simplify try-catching during polymorphic Json operations."
  • change: Merge remote-tracking branch 'origin/master' into dev
  • change: Poison AGENTS.md and add LLM policy (#3318)
  • change: Prepare 1.13.0 release

Architecture

  • Unchanged — 0 containers · 9 contexts · 11 edges

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

Kotlin/kotlinx.serialization was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 13 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 99172ab9ff063e16466226bbeb9a5d00703bbf41 — the exact code this score is about.
  • Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.64+preprod-569132d3dfbe.