SerialKind

sealed class SerialKind(source)

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

Kind is used by serialization formats to determine how exactly the given type should be serialized. For example, JSON format detects the kind of the value and, depending on that, may write it as a plain value for primitive kinds, open a curly brace '{' for class-like structures and square bracket '[' for list- and array- like structures.

Kinds are used both during serialization, to serialize a value properly and statically, and to introspect the type structure or build serialization schema.

Kind should match the structure of the serialized form, not the structure of the corresponding Kotlin class. Meaning that if serializable class class IntPair(val left: Int, val right: Int) is represented by the serializer as a single Long value, its descriptor should have PrimitiveKind.LONG without nested elements even though the class itself represents a structure with two primitive fields.

Inheritors

Types

Link copied to clipboard

Represents an "unknown" type that will be known only at the moment of the serialization. Effectively it defers the choice of the serializer to a moment of the serialization, and can be used for contextual serialization.

Link copied to clipboard
object ENUM : SerialKind

Represents a Kotlin Enum with statically known values. All enum values should be enumerated in descriptor elements. Each element descriptor of a Enum kind represents an instance of a particular enum and has an StructureKind.OBJECT kind. Each positional name contains a corresponding enum element name.

Functions

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String