I am tring Qt5. I try to read values from a json file. Json file is like the one above:
test.json
[{"w":188,"h":334,"th":0.350000,"l":232,"r":420,"t":133,"b":467,"p":0.713963,"n":"person"}]
[{"w":127,"h":141,"th":0.350000,"l":1152,"r":1279,"t":162,"b":303,"p":0.408129,"n":"person"},{"w":179,"h":339,"th":0.350000,"l":230,"r":409,"t":131,"b":470,"p":0.698172,"n":"person"}]
It's under code I try. How to read such a json file structure ?
QString val;
QFile file;
file.setFileName("test.json");
file.open(QIODevice::ReadOnly | QIODevice::Text);
//file is readall
val = file.readAll();
file.close();
qWarning() << val; //print consol
QJsonDocument jsonDocument = QJsonDocument::fromJson(val.toUtf8());
//get data array !!!
QJsonObject jsonObject = jsonDocument.object();
QJsonArray jsonArray = jsonObject["w"].toArray();
qWarning() << jsonArray[0].toString();
[values1] [values2]not json