From a243aae5bbd133375963f8f2890847d26d3e0c75 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 26 Dec 2020 18:14:59 +0100 Subject: [PATCH] Update Bintrayclient to ArduinoJson 6.x --- lib/BintrayClient/src/BintrayClient.cpp | 20 +++++++++++--------- platformio_orig.ini | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/BintrayClient/src/BintrayClient.cpp b/lib/BintrayClient/src/BintrayClient.cpp index 955bca20..34fa357f 100644 --- a/lib/BintrayClient/src/BintrayClient.cpp +++ b/lib/BintrayClient/src/BintrayClient.cpp @@ -113,16 +113,17 @@ String BintrayClient::getLatestVersion() const ESP_LOGE(TAG, "Error: Firmware version data invalid."); return version; } - StaticJsonBuffer jsonBuffer; + StaticJsonDocument doc; + + DeserializationError err = deserializeJson(doc, jsonResult.c_str()); - JsonObject &root = jsonBuffer.parseObject(jsonResult.c_str()); // Check for errors in parsing - if (!root.success()) + if (err) { ESP_LOGE(TAG, "Error: Firmware version data not found."); return version; } - return root.get("name"); + return doc["name"].as(); } String BintrayClient::getBinaryPath(const String &version) const @@ -137,14 +138,15 @@ String BintrayClient::getBinaryPath(const String &version) const ESP_LOGE(TAG, "Error: Firmware download path data invalid."); return path; } - StaticJsonBuffer jsonBuffer; + StaticJsonDocument doc; - JsonArray &root = jsonBuffer.parseArray(jsonResult.c_str()); - JsonObject &firstItem = root[0]; - if (!root.success()) + DeserializationError err = deserializeJson(doc, jsonResult.c_str()); + + JsonObject firstItem = doc[0]; + if (err) { //Check for errors in parsing ESP_LOGE(TAG, "Error: Firmware download path not found."); return path; } - return "/" + getUser() + "/" + getRepository() + "/" + firstItem.get("path"); + return "/" + getUser() + "/" + getRepository() + "/" + firstItem["path"].as(); } diff --git a/platformio_orig.ini b/platformio_orig.ini index 3e6a6b9d..3b013c97 100644 --- a/platformio_orig.ini +++ b/platformio_orig.ini @@ -79,7 +79,7 @@ lib_deps_sensors = boschsensortec/BSEC Software Library @ 1.6.1480 https://github.com/ricki-z/SDS011.git lib_deps_basic = - bblanchon/ArduinoJson @ <6 + bblanchon/ArduinoJson @ ^6 jchristensen/Timezone @ ^1.2.4 makuna/RTC @ ^2.3.5 spacehuhn/SimpleButton