5
JSON文件看起来像这样:如何解决getMemberNames()中的JsonCPP错误?
{
"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
是一个arrayValue,我通过获取它的ValueType = 6
来确认它。
你的第一个答案是我的理想的解决方案,但我无法找出如何修改我的PHP代码有一个格式,我已经张贴这个问题在这里,在此期间,我会尝试通过另解决方案:) http://stackoverflow.com/questions/11444171/php-to-json-format – 2012-07-12 02:15:00