Skip to content

Commit 317d127

Browse files
authored
Replace use of deCONZ::jsonStringFromMap() by Json::serialize() (dresden-elektronik#7675)
deCONZ::jsonStringFromMap() is a old function in deCONZ library and about to be removed.
1 parent 5565601 commit 317d127

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

gateway.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* Copyright (c) 2013-2024 dresden elektronik ingenieurtechnik gmbh.
3+
* All rights reserved.
4+
*
5+
* The software in this package is published under the terms of the BSD
6+
* style license a copy of which has been included with this distribution in
7+
* the LICENSE.txt file.
8+
*
9+
*/
10+
111
#include <QBuffer>
212
#include <QNetworkAccessManager>
313
#include <QNetworkReply>
@@ -546,7 +556,7 @@ void GatewayPrivate::handleEventStateNotAuthorized(GW_Event event)
546556
map[QLatin1String("devicetype")] = QLatin1String("x-gw");
547557
//map[QLatin1String("username")] = apikey;
548558

549-
QString json = deCONZ::jsonStringFromMap(map);
559+
QString json = Json::serialize(map);
550560

551561
reqBuffer->close();
552562
reqBuffer->setData(json.toUtf8());
@@ -757,7 +767,7 @@ void GatewayPrivate::handleEventStateConnected(GW_Event event)
757767
{
758768
map[QLatin1String("transitiontime")] = (double) cmd.transitionTime;
759769
}
760-
json = deCONZ::jsonStringFromMap(map);
770+
json = Json::serialize(map);
761771
DBG_Printf(DBG_INFO_L2, "GW body %s\n", qPrintable(json));
762772
}
763773
else

rest_schedules.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2019 dresden elektronik ingenieurtechnik gmbh.
2+
* Copyright (c) 2016-2024 dresden elektronik ingenieurtechnik gmbh.
33
* All rights reserved.
44
*
55
* The software in this package is published under the terms of the BSD
@@ -365,7 +365,7 @@ int DeRestPluginPrivate::setScheduleAttributes(const ApiRequest &req, ApiRespons
365365

366366
if (!cmd.isEmpty() && cmd.contains("address") && cmd.contains("method") && cmd.contains("body"))
367367
{
368-
i->command = deCONZ::jsonStringFromMap(cmd);
368+
i->command = Json::serialize(cmd);
369369
i->jsonMap["command"] = map["command"];
370370

371371
QVariantMap rspItem;
@@ -802,7 +802,7 @@ bool DeRestPluginPrivate::jsonToSchedule(const QString &jsonString, Schedule &sc
802802
return false;
803803
}
804804

805-
schedule.command = deCONZ::jsonStringFromMap(cmd);
805+
schedule.command = Json::serialize(cmd);
806806
}
807807
else
808808
{
@@ -1146,7 +1146,7 @@ void DeRestPluginPrivate::scheduleTimerFired()
11461146
{
11471147
if (i->endtime.isValid() && i->endtime > now)
11481148
{
1149-
DBG_Printf(DBG_INFO, "schedule %s timeout in %d s\n", qPrintable(i->id), now.secsTo(i->endtime));
1149+
DBG_Printf(DBG_INFO, "schedule %s timeout in %d s\n", qPrintable(i->id), (int)now.secsTo(i->endtime));
11501150
continue;
11511151
}
11521152
else if (i->endtime.isValid())
@@ -1226,7 +1226,7 @@ void DeRestPluginPrivate::scheduleTimerFired()
12261226
{
12271227
i->status = QLatin1String("disabled");
12281228
i->jsonMap["status"] = i->status;
1229-
i->jsonString = deCONZ::jsonStringFromMap(i->jsonMap);
1229+
i->jsonString = Json::serialize(i->jsonMap);
12301230
if (i->autodelete)
12311231
{
12321232
DBG_Printf(DBG_INFO, "schedule %s: %s deleted (too old)\n", qPrintable(i->id), qPrintable(i->name));
@@ -1260,7 +1260,7 @@ void DeRestPluginPrivate::scheduleTimerFired()
12601260
{
12611261
i->status = QLatin1String("disabled");
12621262
i->jsonMap["status"] = i->status;
1263-
i->jsonString = deCONZ::jsonStringFromMap(i->jsonMap);
1263+
i->jsonString = Json::serialize(i->jsonMap);
12641264
}
12651265
queSaveDb(DB_SCHEDULES, DB_SHORT_SAVE_DELAY);
12661266
}
@@ -1355,7 +1355,7 @@ void DeRestPluginPrivate::scheduleTimerFired()
13551355
}
13561356
QString method = cmd["method"].toString();
13571357
QString address = cmd["address"].toString();
1358-
QString content = deCONZ::jsonStringFromMap(cmd["body"].toMap());
1358+
QString content = Json::serialize(cmd["body"].toMap());
13591359

13601360
// check if fields contain data
13611361
if (method.isEmpty() || address.isEmpty() || content.isEmpty())

sensor.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013-2021 dresden elektronik ingenieurtechnik gmbh.
2+
* Copyright (c) 2013-2024 dresden elektronik ingenieurtechnik gmbh.
33
* All rights reserved.
44
*
55
* The software in this package is published under the terms of the BSD
@@ -46,7 +46,7 @@ QString SensorFingerprint::toString() const
4646
map["out"] = ls;
4747
}
4848

49-
return deCONZ::jsonStringFromMap(map);
49+
return Json::serialize(map);
5050
}
5151

5252
/*! Parses a fingerprint from JSON string.

0 commit comments

Comments
 (0)