Hi Can you explain how to parse the nested json response file in qt4.7 (C++). And the file is in the path "/home/kkk/response.json".The file contains the below response.Iam using Qt in Linux environment.
{ " respcode ":" 200 "," respdesc ":"success"," count ":"3",
" nodalofficers ":[
{" attid ":"XXX"," attname ":"XXX"},
{" attid ":"XXX"," attname ":"XXX"},
{" attid ":"XXX"," attname ":"XXX"}]
}
What I have tried:
I have tried below code but here I dont know how to declare Jsondocument(document) thats why getting errors.
QStringList countlist = document.elementsByTagName("nodalofficers");
if(countlist.isEmpty())
{
DisplayWideMsgBox("Invalid Response Received \nPlease Try Again");
return -1;
}
int itemCount = countlist.at(0).childNodes().count();
qDebug()<<"COUNT :"<<itemCount;
list = document.elementsByTagName("nodalofficers");
if(list.isEmpty())
{
DisplayWideMsgBox("Empty Data Received for domain list");
return -1;
}
for(int i = 0,j = 0;i < itemCount;i++,j = 0)
{
QString attid =
list.at(i).childNodes().at(j).toElement().text();
QString attname =
list.at(i).childNodes().at(j+1).toElement().text();
}