Skip to content

Decode CBOR to primitive data types #39

Description

@felipheggaliza

Hi,

I still didn't figure out how to decode CBOR to primitive data types. Can you give me an example?

I have been trying this:

ByteArrayInputStream bais = new ByteArrayInputStream(data);
List<DataItem> dataItems = null;
try {
dataItems = new CborDecoder(bais).decode();
} catch (CborException e) {
e.printStackTrace();
}
JsonObject jsonResponseObject = null;
for (DataItem dataItem : dataItems) {
// process data item
Log.d(TAG, "Decoded CBOR: " + dataItem.toString());
Log.d(TAG, "Decoded CBOR: " + dataItem.getMajorType().toString());
}

Output:

Decoded CBOR: SIMPLE_VALUE
Decoded CBOR: MAP

I am expecting a boolean value instead of words: SIMPLE_VALUE or MAP. How can I fix it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions