Добавляем чтение Json в unsigned long

This commit is contained in:
2022-02-01 20:39:51 +03:00
parent ac0d82f74e
commit fabe47bed4
2 changed files with 17 additions and 0 deletions

View File

@@ -12,6 +12,21 @@ void jsonWriteStrDoc(DynamicJsonDocument& doc, String name, String value) {
}
// new==============================================================================
bool jsonRead(String& json, String key, unsigned long& value) {
bool ret = true;
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
DeserializationError error = deserializeJson(doc, json);
if (error) {
SerialPrint("EE", F("jsonRead"), error.f_str());
ret = false;
} else if (!doc.containsKey(key)) {
SerialPrint("EE", F("jsonRead"), key + " missing");
ret = false;
}
value = doc[key].as<unsigned long>();
return ret;
}
bool jsonRead(String& json, String key, float& value) {
bool ret = true;
DynamicJsonDocument doc(JSON_BUFFER_SIZE);