Issue
This Content is from Stack Overflow. Question asked by alonzo golanzo
consider the mongo document: {"key1": "value1", "key2": {"subkey1": "subvalue1"}}
, this can be encoded (using python bson module like: bson.encode(DATA)) to the following uint8_t array: [56, 0, 0, 0, 2, 107, 101, 121, 49, 0, 7, 0, 0, 0, 118, 97, 108, 117, 101, 49, 0, 3, 107, 101, 121, 50, 0, 28, 0, 0, 0, 2, 115, 117, 98, 107, 101, 121, 49, 0, 10, 0, 0, 0, 115, 117, 98, 118, 97, 108, 117, 101, 49, 0, 0, 0]
. Now, I use this array to initialize the bson_t struct and use the iterator to find the subdocument for key2
.
Here I want to create another bson_t document from this. I tried using the bson_iter_document() method but it gives me precondition failed: document
error. Maybe i’m not using it right. Is there another way to do it properly?
Solution
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.
This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.