ZCBOR encode a key as a numeric value and not a character string

Hello,

I want to encode a key as a numeric value instead of a string using the ZCBOR library.

I've tried testing this, but each time, the key is converted to a string.

uint8_t cbor_payload[200] = {0};

ZCBOR_STATE_E(encoding_state, 3, cbor_payload, sizeof(cbor_payload), 0);

uint32_t ints[1] = {1};

char var[] = "test";

bool ok = zcbor_map_start_encode(encoding_state, 10);

ok &= zcbor_uint32_encode(encoding_state, ints) &&

       zcbor_tstr_put_term(encoding_state, var, strlen(var));

ok &= zcbor_map_end_encode(encoding_state, 10);

Output: {"1":"test"}

I'd like to have {1:"test"} instead.

Is there a function that can do this?

Looking forward to hearing from you,

Sincerely,

Related