Lionel Briand
09/09/2024, 12:39 PMkotlinx-serialization-cbor
.
https://github.com/L-Briand/obor
I also did some nice additions; for those interested, here is the feature list of this new version :
• It always uses the least number of bytes to encode something. An Int with a value of less than 24 will be encoded to a single byte. A float32 that can be encoded with a float16 will be encoded as a float16.
• Like the JsonObject
, you can use the CborObject
to encode / decode any CBOR messages.
• There are special serializers to serialize and deserialize full range of signed and unsigned values.
• You can create tagged CBOR message with the @CborTag
annotation.
• ByteArray
and types looking like List<Byte>
can be written with Major type 2 instead of Major type 4 with @CborRawBytes
and special serializer.
• Indefinite length is handled automatically on deserialization and can be specified on serialization with @CborIndefinite
or special serializer.
• You can compact the serialization of a class to its ordered properties with @CborTuple
. { a: "foo", b: 0 }
-> [ "foo", 0 ]
• You can shrink down the serialization further if a @CborTuple
is in a list with @CborTuple.inlineInList
. [{ a: "foo", b: 0 }, { a: "bar", b: 1 }]
-> [ "foo", 0, "bar", 1]