LongAsStringSerializer

Serializer that encodes and decodes Long as its string representation.

Intended to be used for interoperability with external clients (mainly JavaScript ones), where numbers can't be parsed correctly if they exceed abs(2^53-1).

Properties

Link copied to clipboard
open override val descriptor: SerialDescriptor

Describes the structure of the serializable representation of T, produced by this serializer. Knowing the structure of the descriptor is required to determine the shape of the serialized form (e.g. what elements are encoded as lists and what as primitives) along with its metadata such as alternative names.

Link copied to clipboard

Returns a nullable serializer for the given serializer of non-null type.

Functions

Link copied to clipboard
open override fun deserialize(decoder: Decoder): Long

Deserializes the value of type T using the format that is represented by the given decoder. deserialize method is format-agnostic and operates with a high-level structured Decoder API. As long as most of the formats imply an arbitrary order of properties, deserializer should be able to decode these properties in an arbitrary order and in a format-agnostic way. For that purposes, CompositeDecoder.decodeElementIndex-based loop is used: decoder firstly signals property at which index it is ready to decode and then expects caller to decode property with the given index.

Link copied to clipboard
open override fun serialize(encoder: Encoder, value: Long)

Serializes the value of type T using the format that is represented by the given encoder. serialize method is format-agnostic and operates with a high-level structured Encoder API. Throws SerializationException if value cannot be serialized.