c++ - Boost Property tree - 处理一个空的孩子
问题描述
我正在尝试使用 Boost PropertyTree 库将一些信息转储到导出文件中。我已将文档变红,但遇到了一个问题 - 当将空属性树分配为儿子时,它表示为空字符串而不是空字典。在这种情况下,我尝试使用一种解决方法并返回一个 empty_ptree,但这没有帮助。任何建议将不胜感激。
Code :
//path = pwd
ptree main;
ptree test1;
ptree test2;
test1.put("key", "value")
main.put_child("test1_key", test1);
main.put_child("test2_key", test2);
write_json(path, main)
result :
{
"test1": {
"key": "value"
},
"test2": "" //bad - expected it to be a dictionary as well.
}
expected :
result :
{
"test1": {
"key": "value"
},
"test2": {}
}
解决方案
推荐阅读
- git - Git 终端语言在“git checkout”后更改为另一个分支
- php - WooCommerce 自动分配产品类别和产品状态
- r - 恢复图形参数时的警告
- python - 解析财务报表时无法解决字典更新值错误
- python - 如何通过 Selenium 和 Python 向 Instagram 中的用户名和密码字段发送文本
- python-3.x - Python 3 Tkinter 按钮命令不起作用(非常具体的场景)
- kotlin - 具有 Kotlin 依赖项的 OSGi 项目
- javascript - 如何在多个标签中使用类名添加 ID?
- swift - 状态栏中的自定义视图未在辅助屏幕上显示为禁用
- javascript - 使用js生成时出现div的文本