decode

fun decode(encodedCbor: ByteArray, offset: Int): Pair<Int, DataItem>

Low-level function to decode CBOR.

This decodes a single CBOR data item and also returns the offset of the given byte array of the data that was consumed.

Return

a pair where the first value is the ending offset and the second value is the decoded data item.

Parameters

encodedCbor

the bytes of the CBOR to decode.

offset

the offset into the byte array to start decoding.

Throws

if the data isn't valid CBOR.


fun decode(encodedCbor: ByteArray): DataItem

Decodes CBOR.

The given ByteArray should contain the bytes of a single CBOR data item.

Return

a DataItem with the decoded data.

Parameters

encodedCbor

the bytes of the CBOR to decode.

Throws

if bytes are left over or the data isn't valid CBOR.