JSON 文件如下所示:
{
"strings": [
{
"key_one": "value_one!"
},
{
"key_two": "value_two!"
},
]
}
C++ 文件如下所示:
Json::Value root;
Json::Reader reader;
bool parsingSuccessful = reader.parse(contents, root);
const Json::Value strings = root["strings"];
std::vector<std::string> list = strings.getMemberNames();
“strings.getMemberNames()”引起的错误是:
Assertion failed: (type_ == nullValue || type_ == objectValue), function getMemberNames, file /projects/.../jsoncpp.cpp,
strings
是一个数组值,我通过获取它来确认它ValueType = 6
。