refactor: pass JSON response roots directly to toJson

This commit is contained in:
Yurii committed 2026-12-05 09:30:34 +03:00
1 parent 6b2db61d8f
commit 2ad969bcab
1 file changed
+7 -14
+7 -14
View File
@@ -742,8 +742,7 @@ static void restApi() {
// Prepare response
auto *response = new AsyncJsonResponse();
auto& doc = response->getRoot();
toJson(*sensorId, *sensor, doc);
toJson(*sensorId, *sensor, response->getRoot());
// Send response
response->setLength();
@@ -823,9 +822,8 @@ static void restApi() {
// Prepare response
auto *response = new AsyncJsonResponse();
auto& responseDoc = response->getRoot();
if (const auto sensor = Sensors::getSettings(*sensorId)) {
toJson(*sensorId, *sensor, responseDoc);
toJson(*sensorId, *sensor, response->getRoot());
}
// Send response
@@ -858,8 +856,7 @@ static void restApi() {
// Prepare response
auto *response = new AsyncJsonResponse();
auto& doc = response->getRoot();
toJson(sensor->settings, sensor->result, doc);
toJson(sensor->settings, sensor->result, response->getRoot());
// Send response
response->setLength();
@@ -912,8 +909,7 @@ static void restApi() {
// Prepare response
auto *response = new AsyncJsonResponse();
auto& responseDoc = response->getRoot();
toJson(sensor->settings, sensor->result, responseDoc);
toJson(sensor->settings, sensor->result, response->getRoot());
// Send response
response->setLength();
@@ -988,8 +984,7 @@ static void restApi() {
// Prepare response
auto *response = new AsyncJsonResponse();
auto& responseDoc = response->getRoot();
toJson(sensor->settings, sensor->result, responseDoc);
toJson(sensor->settings, sensor->result, response->getRoot());
// Send response
response->setLength();
@@ -1002,8 +997,7 @@ static void restApi() {
webServer->on("/api/vars", HTTP_GET, [](AsyncWebServerRequest *request) {
// Prepare response
auto *response = new AsyncJsonResponse();
auto& doc = response->getRoot();
toJson(vars, doc);
toJson(vars, response->getRoot());
// Send response
response->setLength();
@@ -1025,8 +1019,7 @@ static void restApi() {
// Prepare response
auto *response = new AsyncJsonResponse();
auto& responseDoc = response->getRoot();
toJson(vars, responseDoc);
toJson(vars, response->getRoot());
// Send response
response->setLength();