Qt Code:
  1. {
  2. "physicaldrives":
  3. [
  4. {
  5. "data":
  6. {
  7. "dev_id": "0",
  8. "ssd_life_left": "0"
  9. }
  10. },
  11. {
  12. "data":
  13. {
  14. "dev_id": "1",
  15. "ssd_life_left": "10"
  16.  
  17. }
  18. }
  19. ]
  20. }
To copy to clipboard, switch view to plain text mode 


this is snippet of JSON how can I parse it in Qt 5

i have tried this
Qt Code:
  1. QString strReply = (QString)reply->readAll();
  2.  
  3. QStringList phydata;
  4.  
  5. QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
  6. if(jsonResponse.isEmpty())
  7. return false;
  8.  
  9. QJsonObject jsonObj = jsonResponse.object();
  10. QJsonArray jsonArray = jsonObj["physicaldrives"].toArray();
  11. if(jsonArray.isEmpty())
  12. return false;
  13. qDebug()<< "jsonArray phyDatas" << jsonArray ;
  14.  
  15. // fatching JSONArray of Ph
  16. foreach (const QJsonValue & value, jsonArray)
  17. {
  18. QJsonObject obj = value.toObject();
  19. phydata.append(obj["data"].toString());
  20. qDebug()<< "phyDatas" << phydata ;
  21. }
  22.  
  23. // fatching value from JSONArray
  24. QJsonValue val = obj["dev_id"];
  25.  
  26. qDebug()<< "devID" << val.toInt(); ;
To copy to clipboard, switch view to plain text mode 
but I dont know its right way or not?
how can I get list of "drv_id" of "data" object ??????