kotlinx-serialization / kotlinx.serialization.builtins / AbstractDecoder

AbstractDecoder

(common, js, jvm, native) abstract class AbstractDecoder : Decoder, CompositeDecoder

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.

Constructors

(common, js, jvm, native)

<init>

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.

<init>()

Properties

(common, js, jvm, native)

context

Context of the current serialization process, including contextual and polymorphic serialization and, potentially, a format-specific configuration.

open val context: SerialModule
(common, js, jvm, native)

updateMode

open val updateMode: UpdateMode

Functions

(common, js, jvm, native)

beginStructure

Decodes the beginning of the nested structure in a serialized form and returns CompositeDecoder responsible for decoding this very structure.

open fun beginStructure(descriptor: SerialDescriptor, vararg typeParams: KSerializer<*>): CompositeDecoder
(common, js, jvm, native)

decodeBoolean

Decodes a boolean value. Corresponding kind is PrimitiveKind.BOOLEAN.

open fun decodeBoolean(): Boolean
(common, js, jvm, native)

decodeBooleanElement

Decodes a boolean value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.BOOLEAN kind.

fun decodeBooleanElement(descriptor: SerialDescriptor, index: Int): Boolean
(common, js, jvm, native)

decodeByte

Decodes a single byte value. Corresponding kind is PrimitiveKind.BYTE.

open fun decodeByte(): Byte
(common, js, jvm, native)

decodeByteElement

Decodes a single byte value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.BYTE kind.

fun decodeByteElement(descriptor: SerialDescriptor, index: Int): Byte
(common, js, jvm, native)

decodeChar

Decodes a 16-bit unicode character value. Corresponding kind is PrimitiveKind.CHAR.

open fun decodeChar(): Char
(common, js, jvm, native)

decodeCharElement

Decodes a 16-bit unicode character value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.CHAR kind.

fun decodeCharElement(descriptor: SerialDescriptor, index: Int): Char
(common, js, jvm, native)

decodeDouble

Decodes a 64-bit IEEE 754 floating point value. Corresponding kind is PrimitiveKind.DOUBLE.

open fun decodeDouble(): Double
(common, js, jvm, native)

decodeDoubleElement

Decodes a 64-bit IEEE 754 floating point value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.DOUBLE kind.

fun decodeDoubleElement(descriptor: SerialDescriptor, index: Int): Double
(common, js, jvm, native)

decodeEnum

Decodes a enum value and returns its index in enumDescriptor elements collection. Corresponding kind is UnionKind.ENUM_KIND.

open fun decodeEnum(enumDescriptor: SerialDescriptor): Int
(common, js, jvm, native)

decodeFloat

Decodes a 32-bit IEEE 754 floating point value. Corresponding kind is PrimitiveKind.FLOAT.

open fun decodeFloat(): Float
(common, js, jvm, native)

decodeFloatElement

Decodes a 32-bit IEEE 754 floating point value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.FLOAT kind.

fun decodeFloatElement(descriptor: SerialDescriptor, index: Int): Float
(common, js, jvm, native)

decodeInt

Decodes a 32-bit integer value. Corresponding kind is PrimitiveKind.INT.

open fun decodeInt(): Int
(common, js, jvm, native)

decodeIntElement

Decodes a 32-bit integer value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.INT kind.

fun decodeIntElement(descriptor: SerialDescriptor, index: Int): Int
(common, js, jvm, native)

decodeLong

Decodes a 64-bit integer value. Corresponding kind is PrimitiveKind.LONG.

open fun decodeLong(): Long
(common, js, jvm, native)

decodeLongElement

Decodes a 64-bit integer value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.LONG kind.

fun decodeLongElement(descriptor: SerialDescriptor, index: Int): Long
(common, js, jvm, native)

decodeNotNullMark

Returns true if the current value in decoder is not null, false otherwise. This method is usually used to decode potentially nullable data:

open fun decodeNotNullMark(): Boolean
(common, js, jvm, native)

decodeNull

Decodes the null value and returns it.

open fun decodeNull(): Nothing?
(common, js, jvm, native)

decodeNullableSerializableElement

Delegates decoding nullable value of the type T to the given deserializer.

fun <T : Any> decodeNullableSerializableElement(descriptor: SerialDescriptor, index: Int, deserializer: DeserializationStrategy<T?>): T?
(common, js, jvm, native)

decodeSerializableElement

Delegates decoding value of the type T to the given deserializer.

fun <T> decodeSerializableElement(descriptor: SerialDescriptor, index: Int, deserializer: DeserializationStrategy<T>): T
(common, js, jvm, native)

decodeShort

Decodes a 16-bit short value. Corresponding kind is PrimitiveKind.SHORT.

open fun decodeShort(): Short
(common, js, jvm, native)

decodeShortElement

Decodes a 16-bit short value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.SHORT kind.

fun decodeShortElement(descriptor: SerialDescriptor, index: Int): Short
(common, js, jvm, native)

decodeString

Decodes a string value. Corresponding kind is PrimitiveKind.STRING.

open fun decodeString(): String
(common, js, jvm, native)

decodeStringElement

Decodes a string value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.STRING kind.

fun decodeStringElement(descriptor: SerialDescriptor, index: Int): String
(common, js, jvm, native)

decodeUnit

open fun decodeUnit(): Unit
(common, js, jvm, native)

decodeUnitElement

fun decodeUnitElement(descriptor: SerialDescriptor, index: Int): Unit
(common, js, jvm, native)

decodeValue

Invoked to decode a value when specialized encode* method was not overridden.

open fun decodeValue(): Any
(common, js, jvm, native)

endStructure

Denotes the end of the structure associated with current decoder. For example, composite decoder of JSON format will expect (and parse) a closing bracket in the underlying input.

open fun endStructure(descriptor: SerialDescriptor): Unit
(common, js, jvm, native)

updateNullableSerializableElement

fun <T : Any> updateNullableSerializableElement(descriptor: SerialDescriptor, index: Int, deserializer: DeserializationStrategy<T?>, old: T?): T?
(common, js, jvm, native)

updateSerializableElement

fun <T> updateSerializableElement(descriptor: SerialDescriptor, index: Int, deserializer: DeserializationStrategy<T>, old: T): T