Добавляем функцию чтения из Json в Float

This commit is contained in:
2022-02-01 20:28:17 +03:00
parent d5909c1c72
commit ac0d82f74e

View File

@@ -12,6 +12,21 @@ void jsonWriteStrDoc(DynamicJsonDocument& doc, String name, String value) {
}
// new==============================================================================
bool jsonRead(String& json, String key, float& 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<float>();
return ret;
}
bool jsonRead(String& json, String key, String& value) {
bool ret = true;
DynamicJsonDocument doc(JSON_BUFFER_SIZE);