使用 jsoncpp,如果我使用以下代码,我会得到一个带有注释的根节点和 nullValue 的 Json::ValueType:
std::string somejson("// Configuration options\
{\
// Default encoding for text\
\"encoding\" : \"UTF-8\",\
\
// Plug-ins loaded at start-up\
\"plug-ins\" : [\
\"python\",\
\"c++\",\
\"ruby\"\
],\
\
// Tab indent size\
\"indent\" : { \"length\" : 3, \"use_space\": true }\
}");
Json::Value root;
Json::Reader reader;
reader.parse(somejson, root);
但是,如果我自己创建一个空的根节点并添加注释,它就会爆炸:
Json::Value rootNode = Json::Value(Json::nullValue);
rootNode.setComment("My wonderful comment", Json::commentBefore);
我做的事情真的很愚蠢吗?有没有人有任何提示?