这是我一直用来阅读boost::property_tree::json_parser::read_json
的json文件的同伦
它始终有效。
/**********************************************/
/* the title */
/**********************************************/
{
"garden": {
"side1": {
"treeA1": "apple",
"treeA2": "orange",
"treeA3": "banana",
},
"side2": {
"treeB1": "orange",
"treeB2": "palm",
"treeB3": "cherry",
}
},
"house": ""
}
我将我的 boost 版本从 1.58.0
升级到 1.65.0
,现在我收到了因为评论的异常。当我删除评论时,一切都很好。
是我哪里弄错了还是新版boost的bug?
最佳答案
评论不是 JSON。
旧的解析器确实有它们,但没有正确支持 unicode。
这是 the release notes for Boost 1.59.0 中的消息:
Property Tree:
- A new JSON parser with full Unicode support.
- Breaking change: The new parser does not support comments or string concatenation in JSON files. These features were non-standard extensions of the old parser but their removal could break code which was relying on them.
关于c++ - 是否允许在 JSON 文件中对 boost read_json 进行注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46187201/