JsonCpp Assertion `type_ == nullValue || type_ == objectValu
发布时间:2020-12-16 19:22:28 所属栏目:百科 来源:网络整理
导读:JsonCpp Assertion `type_ == nullValue || type_ == objectValue' 问题解决,希望能帮助到大家.转载请注明出处. 源程序 Json::Features features = Json::Features::strictMode();Json::Reader reader(features);Json::Value value;stringszbuffer(szRecvBuf
JsonCpp Assertion `type_ == nullValue || type_ == objectValue' 问题解决,希望能帮助到大家.转载请注明出处.
源程序 Json::Features features = Json::Features::strictMode(); Json::Reader reader(features); Json::Value value; string szbuffer(szRecvBuffer); string szName; int nAge; printf("szRecvBuffer:%sn",szRecvBuffer); if(reader.parse(szbuffer,value)) { int nSize =value.size(); for(int i =0; i <nSize; i++) { szName =value["name"].asString(); nAge =value["age"].asInt(); cout<<szName<<endl; cout<<nAge<<endl; } }
可通过程序 Json::Features features = Json::Features::strictMode(); Json::Reader reader(features); Json::Value value; string szbuffer(szRecvBuffer); string szName; int nAge; printf("szRecvBuffer:%sn",value)) { int nSize =value.size(); for(int i =0; i <nSize; i++) { szName =value[i]["name"].asString(); nAge =value[i]["age"].asInt(); cout<<szName<<endl; cout<<nAge<<endl; } } 无非是在value后加了区别的下标.
[{},{}] 与 {} 格式的解析要一致,否则会造成错误
此错误原因,主要是来自,所发的Json格式,和所接收的Json格式要统一.
数组格式,对数组格式. 单条记录格式,对单条记录格式. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |