diff --git a/include/WebApi_Huawei.h b/include/WebApi_Huawei.h index 7484a7ff..021fa015 100644 --- a/include/WebApi_Huawei.h +++ b/include/WebApi_Huawei.h @@ -8,7 +8,7 @@ class WebApiHuaweiClass { public: void init(AsyncWebServer& server); void loop(); - void getJsonData(JsonObject& root); + void getJsonData(JsonVariant& root); private: void onStatus(AsyncWebServerRequest* request); void onAdminGet(AsyncWebServerRequest* request); diff --git a/src/WebApi_Huawei.cpp b/src/WebApi_Huawei.cpp index 586e2ab9..77d96a1a 100644 --- a/src/WebApi_Huawei.cpp +++ b/src/WebApi_Huawei.cpp @@ -28,7 +28,7 @@ void WebApiHuaweiClass::loop() { } -void WebApiHuaweiClass::getJsonData(JsonObject& root) { +void WebApiHuaweiClass::getJsonData(JsonVariant& root) { const RectifierParameters_t * rp = HuaweiCan.get(); root["data_age"] = (millis() - HuaweiCan.getLastUpdate()) / 1000; @@ -62,7 +62,7 @@ void WebApiHuaweiClass::onStatus(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject root = response->getRoot(); + auto& root = response->getRoot(); getJsonData(root); response->setLength(); @@ -76,7 +76,7 @@ void WebApiHuaweiClass::onPost(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject retMsg = response->getRoot(); + auto& retMsg = response->getRoot(); retMsg["type"] = "warning"; if (!request->hasParam("data", true)) { @@ -186,7 +186,7 @@ void WebApiHuaweiClass::onAdminGet(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject root = response->getRoot(); + auto& root = response->getRoot(); const CONFIG_T& config = Configuration.get(); root["enabled"] = config.Huawei.Enabled; @@ -208,7 +208,7 @@ void WebApiHuaweiClass::onAdminPost(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject retMsg = response->getRoot(); + auto& retMsg = response->getRoot(); retMsg["type"] = "warning"; if (!request->hasParam("data", true)) { diff --git a/src/WebApi_battery.cpp b/src/WebApi_battery.cpp index 28ef98f3..b8be0562 100644 --- a/src/WebApi_battery.cpp +++ b/src/WebApi_battery.cpp @@ -35,7 +35,7 @@ void WebApiBatteryClass::onStatus(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject root = response->getRoot(); + auto& root = response->getRoot(); const CONFIG_T& config = Configuration.get(); root["enabled"] = config.Battery.Enabled; @@ -61,7 +61,7 @@ void WebApiBatteryClass::onAdminPost(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject retMsg = response->getRoot(); + auto& retMsg = response->getRoot(); retMsg["type"] = "warning"; if (!request->hasParam("data", true)) { diff --git a/src/WebApi_powerlimiter.cpp b/src/WebApi_powerlimiter.cpp index 33810e8d..b566ccd4 100644 --- a/src/WebApi_powerlimiter.cpp +++ b/src/WebApi_powerlimiter.cpp @@ -34,7 +34,7 @@ void WebApiPowerLimiterClass::loop() void WebApiPowerLimiterClass::onStatus(AsyncWebServerRequest* request) { AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject root = response->getRoot(); + auto& root = response->getRoot(); const CONFIG_T& config = Configuration.get(); root["enabled"] = config.PowerLimiter.Enabled; @@ -79,7 +79,7 @@ void WebApiPowerLimiterClass::onAdminPost(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject retMsg = response->getRoot(); + auto& retMsg = response->getRoot(); retMsg["type"] = "warning"; if (!request->hasParam("data", true)) { diff --git a/src/WebApi_powermeter.cpp b/src/WebApi_powermeter.cpp index 2cea7722..9009198b 100644 --- a/src/WebApi_powermeter.cpp +++ b/src/WebApi_powermeter.cpp @@ -35,7 +35,7 @@ void WebApiPowerMeterClass::loop() void WebApiPowerMeterClass::onStatus(AsyncWebServerRequest* request) { AsyncJsonResponse* response = new AsyncJsonResponse(false, 2048); - JsonObject root = response->getRoot(); + auto& root = response->getRoot(); const CONFIG_T& config = Configuration.get(); root["enabled"] = config.PowerMeter.Enabled; @@ -86,7 +86,7 @@ void WebApiPowerMeterClass::onAdminPost(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject retMsg = response->getRoot(); + auto& retMsg = response->getRoot(); retMsg["type"] = "warning"; if (!request->hasParam("data", true)) { @@ -216,7 +216,7 @@ void WebApiPowerMeterClass::onTestHttpRequest(AsyncWebServerRequest* request) } AsyncJsonResponse* asyncJsonResponse = new AsyncJsonResponse(); - JsonObject retMsg = asyncJsonResponse->getRoot(); + auto& retMsg = asyncJsonResponse->getRoot(); retMsg["type"] = "warning"; if (!request->hasParam("data", true)) { diff --git a/src/WebApi_vedirect.cpp b/src/WebApi_vedirect.cpp index 613bf735..4303cc06 100644 --- a/src/WebApi_vedirect.cpp +++ b/src/WebApi_vedirect.cpp @@ -33,7 +33,7 @@ void WebApiVedirectClass::onVedirectStatus(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject root = response->getRoot(); + auto& root = response->getRoot(); const CONFIG_T& config = Configuration.get(); root["vedirect_enabled"] = config.Vedirect.Enabled; @@ -51,7 +51,7 @@ void WebApiVedirectClass::onVedirectAdminGet(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject root = response->getRoot(); + auto& root = response->getRoot(); const CONFIG_T& config = Configuration.get(); root["vedirect_enabled"] = config.Vedirect.Enabled; @@ -69,7 +69,7 @@ void WebApiVedirectClass::onVedirectAdminPost(AsyncWebServerRequest* request) } AsyncJsonResponse* response = new AsyncJsonResponse(); - JsonObject retMsg = response->getRoot(); + auto& retMsg = response->getRoot(); retMsg["type"] = "warning"; if (!request->hasParam("data", true)) { diff --git a/src/WebApi_ws_Huawei.cpp b/src/WebApi_ws_Huawei.cpp index f75abbc1..128d4b0c 100644 --- a/src/WebApi_ws_Huawei.cpp +++ b/src/WebApi_ws_Huawei.cpp @@ -123,7 +123,7 @@ void WebApiWsHuaweiLiveClass::onLivedataStatus(AsyncWebServerRequest* request) } try { AsyncJsonResponse* response = new AsyncJsonResponse(false, 1024U); - JsonVariant root = response->getRoot().as(); + auto& root = response->getRoot(); generateJsonResponse(root); response->setLength(); diff --git a/src/WebApi_ws_battery.cpp b/src/WebApi_ws_battery.cpp index 475b0b66..3a169fbc 100644 --- a/src/WebApi_ws_battery.cpp +++ b/src/WebApi_ws_battery.cpp @@ -92,7 +92,7 @@ void WebApiWsBatteryLiveClass::onLivedataStatus(AsyncWebServerRequest* request) } try { AsyncJsonResponse* response = new AsyncJsonResponse(false, _responseSize); - JsonVariant root = response->getRoot().as(); + auto& root = response->getRoot(); generateJsonResponse(root); response->setLength(); diff --git a/src/WebApi_ws_vedirect_live.cpp b/src/WebApi_ws_vedirect_live.cpp index 430eb9ce..f89e7ecf 100644 --- a/src/WebApi_ws_vedirect_live.cpp +++ b/src/WebApi_ws_vedirect_live.cpp @@ -169,7 +169,7 @@ void WebApiWsVedirectLiveClass::onLivedataStatus(AsyncWebServerRequest* request) } try { AsyncJsonResponse* response = new AsyncJsonResponse(false, _responseSize); - JsonVariant root = response->getRoot(); + auto& root = response->getRoot(); generateJsonResponse(root);