kotlinx-serialization / kotlinx.serialization / SerialFormat

SerialFormat

(common, js, jvm, native) interface 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.

Typically, formats have their specific Encoder and Decoder implementations as private inner classes and do not expose them.

Properties

(common, js, jvm, native)

context

Contains all serializers registered by format user for ContextualSerialization and Polymorphic serialization.

abstract val context: SerialModule

Inheritors

(common, js, jvm, native)

BinaryFormat

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

interface BinaryFormat : SerialFormat
(common, js, jvm, native)

Default

A top-level SerialFormat instance that mimic an instance of Properties and does not have any SerialModule installed.

companion object Default : SerialFormat
(js)

DynamicObjectParser

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

class DynamicObjectParser : SerialFormat
(common, js, jvm, native)

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.

class Properties : SerialFormat
(common, js, jvm, native)

StringFormat

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

interface StringFormat : SerialFormat