A runtime library that makes usage of code generated by kotlinx.serialization compiler plugin. Contains core serialization API, as well as serializers for standard library classes, and ready for use JSON format implementation. Other formats implementations (Protobuf, CBOR) are provided by separate artifacts, but included to this document for integrity.

All Types

(common, js, jvm, native)
kotlinx.serialization.builtins.AbstractDecoder

A skeleton implementation of both Decoder and CompositeDecoder that can be used for simple formats and for testability purpose. Most of the decode* methods have default implementation that delegates decodeValue(value: Any) as TargetType. See Decoder documentation for information about each particular decode* method.

(common, js, jvm, native)
kotlinx.serialization.builtins.AbstractEncoder

A skeleton implementation of both Encoder and CompositeEncoder that can be used for simple formats and for testability purpose. Most of the encode* methods have default implementation that delegates encodeValue(value: Any). See Encoder documentation for information about each particular encode* method.

(common, js, jvm, native)
kotlinx.serialization.BinaryFormat

SerialFormat that allows conversion to and from ByteArray via dump and load methods

(common, js, jvm, native) (extensions in package kotlinx.serialization.builtins)
kotlin.Boolean
(common, js, jvm, native) (extensions in package kotlinx.serialization.builtins)
kotlin.Byte
(common, js, jvm, native)
kotlinx.serialization.cbor.Cbor

Implements encoding and decoding classes to/from bytes using CBOR specification. It is typically used by constructing an application-specific instance, with configured behaviour, and, if necessary, registered custom serializers (in SerialModule provided by context constructor parameter).

(common, js, jvm, native)
kotlinx.serialization.cbor.CborDecodingException
(common, js, jvm, native) (extensions in package kotlinx.serialization.builtins)
kotlin.Char
(common, js, jvm, native)
kotlinx.serialization.CompositeDecoder

CompositeDecoder is a part of decoding process that is bound to a particular structured part of the serialized form, described by the serial descriptor passed to Decoder.beginStructure.

(common, js, jvm, native)
kotlinx.serialization.CompositeEncoder

CompositeEncoder is a part of encoding process that is bound to a particular structured part of the serialized form, described by the serial descriptor passed to Encoder.beginStructure.

(common, js, jvm, native)
kotlinx.serialization.ContextSerializer

This class provides support for retrieving a serializer in runtime, instead of using the one precompiled by the serialization plugin. This serializer is enabled by ContextualSerialization.

(common, js, jvm, native)
kotlinx.serialization.ContextualSerialization

Instructs to use ContextSerializer on an annotated property or type usage. If used on a file, instructs to use ContextSerializer for all listed KClasses.

(common, js, jvm, native)
kotlinx.serialization.Decoder

Decoder is a core deserialization primitive that encapsulates the knowledge of the underlying format and an underlying storage, exposing only structural methods to the deserializer, making it completely format-agnostic. Deserialization process takes a decoder and asks him for a sequence of primitive elements, defined by a deserializer serial form, while decoder knows how to retrieve these primitive elements from an actual format representations.

(common, js, jvm, native)
kotlinx.serialization.DeserializationStrategy

Deserialization strategy defines the serial form of a type T, including its structural description, declared by the descriptor and the actual deserialization process, defined by the implementation of the deserialize method.

(common, js, jvm, native) (extensions in package kotlinx.serialization.builtins)
kotlin.Double
(js)
kotlinx.serialization.DynamicObjectParser

Converts native JavaScript objects into Kotlin ones, verifying their types.

(common, js, jvm, native)
kotlinx.serialization.modules.EmptyModule

A SerialModule which is empty and always returns null.

(common, js, jvm, native)
kotlinx.serialization.Encoder

Encoder is a core serialization primitive that encapsulates the knowledge of the underlying format and its storage, exposing only structural methods to the serializer, making it completely format-agnostic. Serialization process transforms a single value into the sequence of its primitive elements, also called its serial form, while encoding transforms these primitive elements into an actual format representation: JSON string, ProtoBuf ByteArray, in-memory map representation etc.

(common, js, jvm, native) (extensions in package kotlinx.serialization.builtins)
kotlin.Float
(common, js, jvm, native)
kotlinx.serialization.ImplicitReflectionSerializer

This annotation marks declaration which try to obtain serializer implicitly using reflection, e.g. from KClass or instance itself.

(common, js, jvm, native) (extensions in package kotlinx.serialization.builtins)
kotlin.Int
(common, js, jvm, native)
kotlinx.serialization.InternalSerializationApi

Public API marked with this annotation is effectively internal, which means it should not be used outside of kotlinx.serialization. Signature, semantics, source and binary compatibilities are not guaranteed for this API and will be changed without any warnings or migration aids. If you cannot avoid using internal API to solve your problem, please report your use-case to serialization's issue tracker.

(common, js, jvm, native)
kotlinx.serialization.json.Json

The main entry point to work with JSON serialization. It is typically used by constructing an application-specific instance, with configured json-specific behaviour (configuration constructor parameter) and, if necessary, registered custom serializers (in SerialModule provided by context constructor parameter). Then constructed instance can be used either as regular SerialFormat or StringFormat or for converting objects to JsonElement back and forth.

(common, js, jvm, native)
kotlinx.serialization.json.JsonArray

Class representing JSON array, consisting of indexed values, where value is arbitrary JsonElement

(common, js, jvm, native)
kotlinx.serialization.json.JsonArrayBuilder

DSL builder for a JsonArray. To create an instance of builder, use jsonArray.

(common, js, jvm, native)
kotlinx.serialization.json.JsonArraySerializer

External Serializer object providing SerializationStrategy and DeserializationStrategy for JsonArray. It can only be used by with Json format an its input (JsonInput and JsonOutput).

(common, js, jvm, native)
kotlinx.serialization.json.JsonBuilder

Builder to conveniently build Json instances. Properties of this builder are directly matched with properties of JsonConfiguration.

(common, js, jvm, native)
kotlinx.serialization.json.JsonConfiguration

The class responsible for JSON-specific customizable behaviour in Json format.

(common, js, jvm, native)
kotlinx.serialization.json.JsonDecodingException

Thrown when Json has failed to parse the given JSON string or deserialize it to a target class.

(common, js, jvm, native)
kotlinx.serialization.json.JsonElement

Class representing single JSON element. Can be JsonPrimitive, JsonArray or JsonObject.

(common, js, jvm, native)
kotlinx.serialization.json.JsonElementSerializer

External Serializer object providing SerializationStrategy and DeserializationStrategy for JsonElement. It can only be used by with Json format an its input (JsonInput and JsonOutput). Currently, this hierarchy has no guarantees on descriptor content.

(common, js, jvm, native)
kotlinx.serialization.json.JsonEncodingException

Thrown when Json has failed to create a JSON string from the given value.

(common, js, jvm, native)
kotlinx.serialization.json.JsonException

Generic exception indicating a problem with JSON serialization and deserialization.

(common, js, jvm, native)
kotlinx.serialization.json.JsonInput

Decoder used by Json during deserialization. This interface can be used to inject desired behaviour into a serialization process of Json.

(common, js, jvm, native)
kotlinx.serialization.json.JsonLiteral

Class representing JSON literals: numbers, booleans and string. Strings are always quoted.

(common, js, jvm, native)
kotlinx.serialization.json.JsonLiteralSerializer

External Serializer object providing SerializationStrategy and DeserializationStrategy for JsonLiteral. It can only be used by with Json format an its input (JsonInput and JsonOutput).

(common, js, jvm, native)
kotlinx.serialization.json.JsonNull

Class representing JSON null value

(common, js, jvm, native)
kotlinx.serialization.json.JsonNullSerializer

External Serializer object providing SerializationStrategy and DeserializationStrategy for JsonNull. It can only be used by with Json format an its input (JsonInput and JsonOutput).

(common, js, jvm, native)
kotlinx.serialization.json.JsonObject

Class representing JSON object, consisting of name-value pairs, where value is arbitrary JsonElement

(common, js, jvm, native)
kotlinx.serialization.json.JsonObjectBuilder

DSL builder for a JsonObject. To create an instance of builder, use json.

(common, js, jvm, native)
kotlinx.serialization.json.JsonObjectSerializer

External Serializer object providing SerializationStrategy and DeserializationStrategy for JsonObject. It can only be used by with Json format an its input (JsonInput and JsonOutput).

(common, js, jvm, native)
kotlinx.serialization.json.JsonOutput

Encoder used by Json during serialization. This interface can be used to inject desired behaviour into a serialization process of Json.

(common, js, jvm, native)
kotlinx.serialization.json.JsonParametricSerializer

Base class for custom serializers that allows selecting polymorphic serializer without a dedicated class discriminator, on a content basis.

(common, js, jvm, native)
kotlinx.serialization.json.JsonPrimitive

Class representing JSON primitive value. Can be either JsonLiteral or JsonNull.

(common, js, jvm, native)
kotlinx.serialization.json.JsonPrimitiveSerializer

External Serializer object providing SerializationStrategy and DeserializationStrategy for JsonPrimitive. It can only be used by with Json format an its input (JsonInput and JsonOutput).

(common, js, jvm, native)
kotlinx.serialization.json.JsonTransformingSerializer

Base class for custom serializers that allows manipulating an abstract JSON representation of the class before serialization or deserialization.

(common, js, jvm, native) (extensions in package kotlinx.serialization)
kotlin.reflect.KClass
(common, js, jvm, native)
kotlinx.serialization.KSerializer

KSerializer is responsible for the representation of a serial form of a type T in terms of encoders and decoders and for constructing and deconstructing T from/to a sequence of encoding primitives. For classes marked with @Serializable, can be obtained from generated companion extension .serializer() or from serializer() function.

(common, js, jvm, native) (extensions in package kotlinx.serialization.builtins)
kotlin.Long
(common, js, jvm, native)
kotlinx.serialization.builtins.LongAsStringSerializer

Serializer that encodes and decodes Long as its string representation.

(common, js, jvm, native)
kotlinx.serialization.MissingFieldException

Thrown when KSerializer hasn't received property from Decoder, and this property was not optional.

(common, js, jvm, native)
kotlinx.serialization.Polymorphic

Instructs to use PolymorphicSerializer on an annotated property or type usage. When used on class, replaces its serializer with PolymorphicSerializer everywhere.

(common, js, jvm, native)
kotlinx.serialization.PolymorphicKind

Polymorphic kind represents a (bounded) polymorphic value, that is referred by some base class or interface, but its structure is defined by one of the possible implementations. Polymorphic kind is, by its definition, a union kind and is extracted to its own subtype to emphasize bounded and sealed polymorphism common property: not knowing the actual type statically and requiring formats to additionally encode it.

(common, js, jvm, native)
kotlinx.serialization.modules.PolymorphicModuleBuilder

A builder which registers all its content for polymorphic serialization in the scope of baseClass. If baseSerializer is present, registers it as a serializer for baseClass (which will be used if base class is serializable). Subclasses with its serializers can be added via subclass or with.

(common, js, jvm, native)
kotlinx.serialization.PolymorphicSerializer

This class provides support for multiplatform polymorphic serialization for interfaces and abstract classes.

(common, js, jvm, native)
kotlinx.serialization.PrimitiveKind

Values of primitive kinds usually are represented as a single value. All default serializers for Kotlin primitives types and String have primitive kind.

(common, js, jvm, native)
kotlinx.serialization.Properties

Transforms a Serializable class' properties into a single flat Map which consists of string keys and primitive type values, and vice versa. Located in separated kotlinx-serialization-properties artifact.

(common, js, jvm, native)
kotlinx.serialization.protobuf.ProtoBuf

Implements encoding and decoding classes to/from bytes using Proto2 specification. It is typically used by constructing an application-specific instance, with configured specific behaviour and, if necessary, registered custom serializers (in SerialModule provided by context constructor parameter).

(common, js, jvm, native)
kotlinx.serialization.protobuf.ProtobufDecodingException
(common, js, jvm, native)
kotlinx.serialization.protobuf.ProtoId

Specifies protobuf id (a unique number for a field in the protobuf message) assigned to a Kotlin property.

(common, js, jvm, native)
kotlinx.serialization.protobuf.ProtoNumberType

Represents a number format in protobuf encoding.

(common, js, jvm, native)
kotlinx.serialization.protobuf.ProtoType

Instructs to use a particular ProtoNumberType for a property of integer number type. Affect Byte, Short, Int, Long and Char properties and does not affect others.

(common, js, jvm, native)
kotlinx.serialization.Required

Indicates that property must be present during deserialization process, even if it has default value.

(common, js, jvm, native)
kotlinx.serialization.SealedClassSerializer

This class provides support for multiplatform polymorphic serialization of sealed classes.

(common, js, jvm, native)
kotlinx.serialization.SerialDescriptor

Serial descriptor is an inherent property of KSerializer that describes the structure of the serializable type. The structure of the serializable type is not only the property of the type, but also of the serializer as well, meaning that one type can have multiple descriptors that have completely different structure.

(common, js, jvm, native)
kotlinx.serialization.SerialDescriptorBuilder

Builder for SerialDescriptor to be used in custom serializers.

(common, js, jvm, native)
kotlinx.serialization.SerialFormat

Represents an instance of a serialization format that can interact with KSerializer and is a supertype of all entry points for a serialization. It does not impose any restrictions on a serialized form or underlying storage, neither it exposes them. Concrete data types and API for user-interaction are responsibility of a concrete subclass or subinterface, e.g. StringFormat, BinaryFormat or Json.

(common, js, jvm, native)
kotlinx.serialization.SerialInfo

When annotation class is marked with @SerialInfo, compiler plugin can instantiate it and put into SerialDescriptor, to be retrieved later during serialization process.

(common, js, jvm, native)
kotlinx.serialization.Serializable

Sets specific serializer for class, property or type argument. When argument is omitted, plugin will generate default implementation inside the class.

(common, js, jvm, native)
kotlinx.serialization.SerializationException

A generic exception indicating the problem during serialization or deserialization process

(common, js, jvm, native)
kotlinx.serialization.SerializationStrategy

Serialization strategy defines the serial form of a type T, including its structural description, declared by the descriptor and the actual serialization process, defined by the implementation of the serialize method.

(common, js, jvm, native)
kotlinx.serialization.Serializer

Instructs plugin to turn this class into serializer for specified class forClass. However, it would not be used automatically. To apply it on particular class or property, use Serializable or UseSerializers, or ContextualSerialization with runtime registration.

(common, js, jvm, native)
kotlinx.serialization.modules.SerializerAlreadyRegisteredException

Thrown on an attempt to register serializer (for contextual or polymorphic serialization) for some class twice.

(common, js, jvm, native)
kotlinx.serialization.modules.SerializersModuleBuilder

A builder class for SerializersModule DSL. To create an instance of builder, use SerializersModule factory function.

(common, js, jvm, native)
kotlinx.serialization.SerialKind

Serial kind is an intrinsic property of SerialDescriptor that indicates how the corresponding type is structurally represented by its serializer.

(common, js, jvm, native)
kotlinx.serialization.modules.SerialModule

SerialModule is a collection of serializers used by ContextSerializer and PolymorphicSerializer to override or provide serializers at the runtime, whereas at the compile-time they provided by the serialization plugin. It can be considered as a map where serializers can be found using their statically known KClasses.

(common, js, jvm, native)
kotlinx.serialization.modules.SerialModuleCollector

SerialModuleCollector can introspect and accumulate content of any SerialModule via SerialModule.dumpTo, using a visitor-like pattern: contextual and polymorphic functions are invoked for each registered serializer.

(common, js, jvm, native)
kotlinx.serialization.SerialName

Overrides name visible to the runtime part of serialization framework

(common, js, jvm, native) (extensions in package kotlinx.serialization.builtins)
kotlin.Short
(common, js, jvm, native) (extensions in package kotlinx.serialization.builtins)
kotlin.String
(common, js, jvm, native)
kotlinx.serialization.StringFormat

SerialFormat that allows conversion to and from String via stringify and parse methods

(common, js, jvm, native)
kotlinx.serialization.StructureKind

Structure kind represents values with composite structure of nested elements of depth and arbitrary number. We acknowledge following structured kinds:

(common, js, jvm, native)
kotlinx.serialization.Transient

Marks this property invisible for whole serialization framework. Transient properties must have default values.

(common, js, jvm, native)
kotlinx.serialization.UnionKind

Union structure kind represents a tagged union structure, meaning that the type is represent by one of a multiple possible values (potentially unknown). An example of such union kind can be enum or its derivatives, such as "one of known strings".

(common, js, jvm, native)
kotlinx.serialization.UnknownFieldException

Thrown when KSerializer received unknown property index from CompositeDecoder.decodeElementIndex.

(common, js, jvm, native)
kotlinx.serialization.UnstableDefault

This annotation marks declarations with default parameters that are subject to semantic change without a migration path.

(common, js, jvm, native)
kotlinx.serialization.UpdateMode
(common, js, jvm, native)
kotlinx.serialization.UpdateNotSupportedException
(common, js, jvm, native)
kotlinx.serialization.UseSerializers

Adds serializerClasses to serializers resolving process inside the plugin. Each of serializerClasses must implement KSerializer.