kotlinx-serialization / kotlinx.serialization.cbor / Cbor / <init>

<init>

(common, js, jvm, native) <init>(updateMode: UpdateMode = UpdateMode.BANNED, encodeDefaults: Boolean = true, context: SerialModule = EmptyModule)

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).

Known caveats and limitations:

Supports reading collections of both definite and indefinite lengths; however, serialization always writes maps and lists as indefinite-length ones. Does not support optional tags representing datetime, bignums, etc. Fully support CBOR maps, which, unlike JSON ones, may contain keys of non-primitive types, and may produce such maps from corresponding Kotlin objects. However, other 3rd-party parsers (e.g. jackson-dataformat-cbor) may not accept such maps.

Parameters

encodeDefaults - specifies whether default values of Kotlin properties are encoded.