Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C LibBSON导出到缓冲区_C_Bson_Mongodb C - Fatal编程技术网

C LibBSON导出到缓冲区

C LibBSON导出到缓冲区,c,bson,mongodb-c,C,Bson,Mongodb C,我正在寻找一种使用C库将文档复制到缓冲区或文件的方法 我想我遗漏了一些东西-非常感谢您的帮助。将BSON导出到UTF-8而不丢失信息。如果您只需要缓冲区数据,您可以使用BSON获取数据: bson_t * bson = bson_new(); ///// Fill with data // Get data buffer const char * data = reinterpret_cast<const char*>(bson_get_data(bson)); int lengt

我正在寻找一种使用C库将文档复制到缓冲区或文件的方法


我想我遗漏了一些东西-非常感谢您的帮助。

将BSON导出到UTF-8而不丢失信息。

如果您只需要缓冲区数据,您可以使用BSON获取数据:

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;
bson_t*bson=bson_new();
/////填充数据
//获取数据缓冲区
const char*data=reinterpret_cast(bson_get_data(bson));
int length=bson->len;

文档的格式是什么?我添加了两个到相关源页面的链接。@immibis文档位于通过bson\t指针访问的堆上。这就是你所说的格式吗?bson_as_canonical_extended_json()可能会起作用。有没有一种好方法可以像mongodump那样以二进制格式导出bson?@zille yep。我在想你可能把它当成了一个字符数组,却弄错了树:P