will be serialized to raw bytes of the same length, or close to it?
p
Paul Woitaschek
07/20/2020, 8:49 AM
Just try it out, its really easy to setup an intellij sample project and play with it
t
travis
07/20/2020, 7:40 PM
My understanding is that
ByteArray
is serialized as type 4 CBOR byte-by-byte (so seemingly sub-optimal, but I haven't benchmarked to confirm).
Not sure why that design choice, possibly because in the future they want to support serializing from an unknown length stream of data?
PR #898 adds CBOR type 2 serialization of
ByteArray
and serializes the entire
ByteArray
in a single pass (similar to how
String
is serialized).
travis
07/20/2020, 7:46 PM
I guess I'm asking whether a
ByteArray
will be serialized to raw bytes of the same length, or close to it?
Could've just been the data used, but in PR 898, it seems type 4 can sometimes take up more bytes than type 2.
e.g.
0xCAFE
serialized to
0x383521
for type 4 (default type for kotlinx.serialization) and