I have documents in a mongo collection which look like: { "f" : [ 283, 180, 284 ], "l":["1","29"] } I am using the mongoDB c driver to fetch these documents and perform some operations on these> I would like to restore element "f" back as an array of integers and the element "l" back as an two multidimensional char array.
while (mongoc_cursor_next (cursor, &doc))
{
bson_iter_t it;
bson_iter_init(&it, doc);
while (bson_iter_next(&it))
{
const char * key=bson_iter_key(&it);
bson_type_t type=bson_iter_type(&it);
const uint8_t *data = NULL;
uint32_t len = 0;
bson_iter_array (&it, &len, &data);
}
}
I am not able to figure out how I can extract "f" to int* and "l" to char**. I tried to type cast the pointer (data) to different types but the values are not proper. How do I go about it?