I have a JSON nested structure like this: {"var1":"val1","var2":{"var1a":"val1a"}}
I have generated the cbor buffer using this function from the libcbor library.
cbor_item_t *cbor = cjson_cbor_load(json, cjson_cbor_stream_decode);
unsigned char *buffer;
size_t buffer_size;
cbor_serialize_alloc(cbor, &buffer, &buffer_size);
I'd like to generate directly the cbor object without passing by the json object, using this function...
cbor_item_t* root = cbor_new_definite_map(3);
/* Add the content */
cbor_map_add(root, (struct cbor_pair) {
.key = cbor_move(cbor_build_string("Is CBOR awesome?")),
.value = cbor_move(cbor_build_bool(true))
});
But I don't know how to add the nested structure <"var2":{>. Do you have any suggestion? Thank you.