Update Bintrayclient to ArduinoJson 6.x

This commit is contained in:
cyberman54 2020-12-26 18:14:59 +01:00
parent c9b2010b29
commit a243aae5bb
2 changed files with 12 additions and 10 deletions

View File

@ -113,16 +113,17 @@ String BintrayClient::getLatestVersion() const
ESP_LOGE(TAG, "Error: Firmware version data invalid."); ESP_LOGE(TAG, "Error: Firmware version data invalid.");
return version; return version;
} }
StaticJsonBuffer<bufferSize> jsonBuffer; StaticJsonDocument<bufferSize> doc;
DeserializationError err = deserializeJson(doc, jsonResult.c_str());
JsonObject &root = jsonBuffer.parseObject(jsonResult.c_str());
// Check for errors in parsing // Check for errors in parsing
if (!root.success()) if (err)
{ {
ESP_LOGE(TAG, "Error: Firmware version data not found."); ESP_LOGE(TAG, "Error: Firmware version data not found.");
return version; return version;
} }
return root.get<String>("name"); return doc["name"].as<String>();
} }
String BintrayClient::getBinaryPath(const String &version) const 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."); ESP_LOGE(TAG, "Error: Firmware download path data invalid.");
return path; return path;
} }
StaticJsonBuffer<bufferSize> jsonBuffer; StaticJsonDocument<bufferSize> doc;
JsonArray &root = jsonBuffer.parseArray(jsonResult.c_str()); DeserializationError err = deserializeJson(doc, jsonResult.c_str());
JsonObject &firstItem = root[0];
if (!root.success()) JsonObject firstItem = doc[0];
if (err)
{ //Check for errors in parsing { //Check for errors in parsing
ESP_LOGE(TAG, "Error: Firmware download path not found."); ESP_LOGE(TAG, "Error: Firmware download path not found.");
return path; return path;
} }
return "/" + getUser() + "/" + getRepository() + "/" + firstItem.get<String>("path"); return "/" + getUser() + "/" + getRepository() + "/" + firstItem["path"].as<String>();
} }

View File

@ -79,7 +79,7 @@ lib_deps_sensors =
boschsensortec/BSEC Software Library @ 1.6.1480 boschsensortec/BSEC Software Library @ 1.6.1480
https://github.com/ricki-z/SDS011.git https://github.com/ricki-z/SDS011.git
lib_deps_basic = lib_deps_basic =
bblanchon/ArduinoJson @ <6 bblanchon/ArduinoJson @ ^6
jchristensen/Timezone @ ^1.2.4 jchristensen/Timezone @ ^1.2.4
makuna/RTC @ ^2.3.5 makuna/RTC @ ^2.3.5
spacehuhn/SimpleButton spacehuhn/SimpleButton