I'm searching for a way to copy a BSON document to a buffer or into a file using the C-library libbson.
I think I'm missing something - any help is appreciated.
If you only need buffer data, you can use bson_get_data :
bson_t * bson = bson_new();
///// Fill with data
// Get data buffer
const char * data = reinterpret_cast<const char*>(bson_get_data(bson));
int length = bson->len;