CborSerializable
Marks class for automatic CBOR serialization code generation.
CBOR serializer uses a CBOR map that maps Kotlin field names to serialized field values.
Fields with value null
are not written to the serialized map.
The following field types are allowed:
primitive:
Int
,Long
,Float
,Double
,String
,Boolean
time:
Instant
andLocalDate
binary:
ByteString
andByteArray
CBOR generic value:
DataItem
enums
types manually implementing CBOR serialization (annotated by CborSerializationImplemented)
types with automatically generated CBOR serialization (annotated by CborSerializable)
maps, lists, or sets of the above (sets are treated as lists)
nullable variants of the above
Single-level sealed class hierarchies are supported. Annotation is required only on the root class of the sealed hierarchy. A special key ("type" by default, see typeKey) is added to CBOR map to indicate the actual value type (type id). To avoid name conflicts it is recommended that either:
leaf class names include base class name either as a prefix or a suffix (type id is generated from the leaf class name, stripping base class name),
or, leaf classes are scoped in the base class,
or, leaf classes and the base class are scoped in some other class or object,
or, explicit typeId is specified.