Upravy pro nejnovejsi ArduinoJson 7.2.1

This commit is contained in:
Pavel Brychta 2024-12-05 10:34:29 +01:00
parent a42ee82a3a
commit 549a215403

View File

@ -27,7 +27,7 @@ T svGetV(const String & name, const T deflt)
if (err) {
TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: Deserialize error '%s'", err.c_str()); // wrong JSON file (malformed)
} else {
if (!doc.containsKey(name)) {
if (!doc[name].is<JsonVariant>()) { // key not found
TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: Key '%s' not found", name.c_str());
} else {
rv = doc[name].as<T>();
@ -52,7 +52,7 @@ T svGetVFile(const String & name, const String & fname, const T deflt)
if (err) {
TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: Deserialize error '%s'", err.c_str()); // wrong JSON file (malformed)
} else {
if (!doc.containsKey(name)) {
if (!doc[name].is<JsonVariant>()) {
TRACEPLUS(DEBUG_SYSVARS, TRACE_ERROR, "SV: Key '%s' not found", name.c_str());
} else {
rv = doc[name].as<T>();
@ -119,8 +119,7 @@ int svSetVFile(const String & name, T value, const String & fname)
File f = USEDFS.open(fname, "r");
if (f) {
const DeserializationError err = deserializeJson(doc, f);
if (err) {
if (const DeserializationError err = deserializeJson(doc, f)) {
res = SV_DESERIALIZE_ERROR; // wrong (malformed) JSON file
}
f.close();