class Cbor : BinaryFormat
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).
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.
encodeDefaults
- specifies whether default values of Kotlin properties are encoded.
(common, js, jvm, native)
Default |
companion object Default : BinaryFormat |
(common, js, jvm, native)
<init> |
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). <init>(updateMode: UpdateMode = UpdateMode.BANNED, encodeDefaults: Boolean = true, context: SerialModule = EmptyModule) |
(common, js, jvm, native)
context |
Contains all serializers registered by format user for ContextualSerialization and Polymorphic serialization. val context: SerialModule |
(common, js, jvm, native)
encodeDefaults |
specifies whether default values of Kotlin properties are encoded. val encodeDefaults: Boolean |
(common, js, jvm, native)
updateMode |
val updateMode: UpdateMode |
(common, js, jvm, native)
dump |
Serializes value to CBOR bytes using given serializer. fun <T> dump(serializer: SerializationStrategy<T>, value: T): ByteArray |
(common, js, jvm, native)
load |
Loads value of type T from given CBOR bytes using deserializer. fun <T> load(deserializer: DeserializationStrategy<T>, bytes: ByteArray): T |