存到json

This commit is contained in:
hm
2022-02-10 23:42:10 +08:00
parent 492f405701
commit af0185feea
3 changed files with 24 additions and 25 deletions
+16 -7
View File
@@ -346,12 +346,14 @@ void Config::setVirtualMargin(QMap<int, Config::_latlng> mvs,int type)
{
QJsonObject obj = getJsonObject("VirtualMargin");//总
QJsonArray notice_obj = obj.value("orange").toArray();
QJsonArray warning_obj = obj.value("red").toArray();
QJsonArray notice_obj;
QJsonArray warning_obj;
if(type == 0)//红
{
notice_obj = obj.value("orange").toArray();
foreach (Config::_latlng latlng, mvs) {
QJsonObject v;
@@ -359,16 +361,23 @@ void Config::setVirtualMargin(QMap<int, Config::_latlng> mvs,int type)
v["index"] = latlng.index;
v["latitude"] = latlng.latitude;
v["longitude"] = latlng.longitude;
warning_obj.append(v);
}
}
else if(type == 1)//黄
{
foreach (QJsonValue v, notice_obj) {
Config::_latlng latlng;
warning_obj = obj.value("red").toArray();
latlng.index = v.toObject().value("index").toInt();
latlng.latitude = v.toObject().value("latitude").toDouble();
latlng.longitude = v.toObject().value("longitude").toDouble();
foreach (Config::_latlng latlng, mvs) {
QJsonObject v;
v["index"] = latlng.index;
v["latitude"] = latlng.latitude;
v["longitude"] = latlng.longitude;
notice_obj.append(v);
}
}