如何使用C 将Boost Ptree插入MongoDB
How to insert a Boost ptree into MongoDB using C++
我在https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/tutororial/complocile/上汇总并准备好了,用文字数据进行了测试。<<<<<<<<<<<<<<<<<<<,/p>
但挑战是如何将Boost Ptree存储到MongoDB中。我有一个Boost Ptree,因为我正在使用Boost来解析JSON字符串。
该过程如下:
输入 -> JSON String(OK) -> Boost Ptree(OK) -> MongoDB插入(Stuck!)
最终得到了解决方案!
这些是:
- 可以从解析JSON String(Boost Read_json) 获得Ptree
- 检查或修改PTREE对象中的值
- 使用boost write_json 将ptree转换回JSON字符串
- 转换为mongodb bson值: bsoncxx :: document :: value doc = bsoncxx :: from_json(str)
- 插入到db: cxxclient [" dbName"] [" collection"]。
相关文章:
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 预处理器:插入结构名称中的前一个行号
- 在未初始化映射的情况下,将值插入到映射的映射中
- 如何在c++中只将键插入到bimap的一侧
- 如何将结构插入到集合中并打印集合的成员
- C++json插入数组
- Visual Studio 2019:插入多个C++风格的单行注释
- nlohmann-json将一个数组插入到另一个数组中
- 有效地使用std::unordered_map来插入或增加键的值
- 为字符串中每 N 个字符插入空格的函数没有按照我认为的方式工作?
- 正在插入动态数组
- 插入或删除时获取usb的dos_name
- 叮叮当当在修复时插入多个"覆盖"说明符
- 链表c++插入,所有情况都已检查,但没有任何工作
- 将重物插入std::map
- C++17 - 使用自定义分配器的节点提取/重新插入 - 适用于 clang++/libc++,但不适用于 libstd
- 在数字之间插入 + 或 - 符号以使其等于整数
- 在字符串中插入空格
- 如何使用C 将Boost Ptree插入MongoDB