Advertisement

jsoncpp: JSON++头文件头和命名空间声明

阅读量:

解析获取的JSON数据结构

{
"A": [
{
"B": [
{
"C": [
"text"
],
"D": 1,
"E": 0,
"F": "text"
}
],
"G": "text"
}
]
}

将上述内容进行反序列化处理,转换为JSON::value格式进行解析

复制代码
 Json::Value root;

    
 JSONCPP_STRING errs;
    
 Json::CharReaderBuilder jsreader;
    
 std::unique_ptr<Json::CharReader> const reader(jsreader.newCharReader());
    
 bool parse_ok = reader->parse(chunk, LPCSTR(chunk) + chunk.GetLength(), &root, &errs);
    
 if (!parse_ok)
    
 {
    
     cout << "反序列化失败" << endl;
    
     return 1;
    
 }
    
 else
    
 {
    
    //获取到C的值
    
     root["A"][0]["B"][0]["C"

全部评论 (0)

还没有任何评论哟~