Cbor

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 SerializersModule provided by serializersModule 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.

sealed class Cbor : BinaryFormat

Parameters

encodeDefaults

specifies whether default values of Kotlin properties are encoded. False by default; meaning that properties with values equal to defaults will be elided.

ignoreUnknownKeys

specifies if unknown CBOR elements should be ignored (skipped) when decoding.

Types

Default
Link copied to clipboard
common

The default instance of Cbor

object Default : Cbor

Functions

decodeFromByteArray
Link copied to clipboard
common
open override fun <T> decodeFromByteArray(deserializer: DeserializationStrategy<T>, bytes: ByteArray): T
encodeToByteArray
Link copied to clipboard
common
open override fun <T> encodeToByteArray(serializer: SerializationStrategy<T>, value: T): ByteArray
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
toString
Link copied to clipboard
common
open override fun toString(): String

Properties

serializersModule
Link copied to clipboard
common
open override val serializersModule: SerializersModule

Inheritors

Cbor
Link copied to clipboard
common