c++ - 是否允许在 JSON 文件中对 boost read_json 进行注释?

标签 c++ json boost boost-propertytree

这是我一直用来阅读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/

相关文章:

c++ - 将 typedef 方法作为指针函数传递

没有 RTTI 的 C++ 双重分派(dispatch) "extensible"

c++ - 定义宏定义时出错

php - 通过 ajax 将 JSON(从 php)打印到 Bootstrap 模式

c++ - 创建一个非线程安全的 shared_ptr

c++ - 使用 mingw730 32 位的 Qt 5.12 项目发布构建中代码位置的偏移量

javascript - 检查我的字符串是否包含数组中的元素

JavaScript 对象到 JSON 对象

c++ - Boost.Regex 解析

c++ - Boost线程断点