{
"HeWeather6": [{
"basic": {
"cid": "CN101010700",
"location": "昌平",
"parent_city": "北京",
"admin_area": "北京",
"cnty": "中国",
"lat": "40.21808624",
"lon": "116.23590851",
"tz": "+8.00"
},
"update": {
"loc": "2019-07-20 10:21",
"utc": "2019-07-20 02:21"
},
"status": "ok",
"now": {
"cloud": "96",
"cond_code": "104",
"cond_txt": "阴",
"fl": "28",
"hum": "86",
"pcpn": "0.0",
"pres": "995",
"tmp": "25",
"vis": "4",
"wind_deg": "100",
"wind_dir": "东风",
"wind_sc": "1",
"wind_spd": "4"
}
}]
}
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QJsonDocument>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QFile file("test.json");
file.open(QFile::OpenModeFlag::ReadOnly);
QByteArray data = file.readAll();
file.close();
QJsonDocument jsondocument = QJsonDocument::fromJson(data);
qDebug() << jsondocument["HeWeather6"][0]["basic"]["admin_area"].toString();
return a.exec();
}