因为要用到调试json的解析结果,所以在这里写了一个,结果近似json格式
void PrintJsonList(const string & paramPre, Json::Value & paramValue)
{
Json::Value::Members mem = paramValue.getMemberNames();
for (auto iter = mem.begin(); iter != mem.end(); iter++)
{
cout<<paramPre<<"\""<<*iter<<"\":";
if (paramValue[*iter].type() == Json::objectValue)
{
cout<<paramPre<<"{"<<endl;
PrintJsonList(paramPre + " ", paramValue[*iter]);
cout<<paramPre<<"},"<<endl;
}
else if (paramValue[*iter].type() == Json::arrayValue)
{
cout<<paramPre<<"["<<endl;
auto cnt = paramValue[*iter].size();
for (auto i = 0; i < cnt; i++)
{
Json::Value & pElem = paramValue[*iter][i];
if (pElem.type() == Json::arrayValue)
{
cout <<paramPre<< "["<<endl;
PrintJsonList(paramPre + " ", pElem);
cout <<paramPre<< "],"<<endl;
}
else if (pElem.type() == Json::objectValue)
{
cout <<paramPre<< "{"<<endl;
PrintJsonList(paramPre + " ", pElem);
cout <<paramPre<< "},"<<endl;
}
else PrintJsonList(paramPre + " ", pElem);
}
cout<<paramPre<<"]"<<endl;
}
else if (paramValue[*iter].type() == Json::stringValue)
{
cout<<"\""<<paramValue[*iter].asString()<<"\""<<endl;
}
else if (paramValue[*iter].type() == Json::realValue)
{
cout<<paramValue[*iter].asDouble()<<endl;
}
else if (paramValue[*iter].type() == Json::uintValue)
{
cout<<paramValue[*iter].asUInt()<<endl;
}
else
{
cout<<paramValue[*iter].asInt()<<endl;
}
}
return;
}