I would like to deserialize a generic cbor object using kotlinx-serialization
, including tags etc., without knowing much about its structure. Basically an equivalent to a JsonObject, but for Cbor.
Is it possible to deserialize a cbor object without a serialization strategy to receive such a generic Cbor object?
How would one go about writing a custom kotlinx-serialization-compliant Cbor serialization extension to support this?
I tried implementing this using a hierarchy of sealed types, but this doesn’t work since there won’t (and shouldn’t) be a separate type discriminator.
I also tried implementing a custom serializer, but this would require a one-byte lookahead in order to determine the (major) type of the next element that is to be decoded.
Simply implementing a method to deserialize a byte array is not possible since this object is part of a bigger structure.