mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
Добавляем функцию чтения из Json в Float
This commit is contained in:
@@ -12,6 +12,21 @@ void jsonWriteStrDoc(DynamicJsonDocument& doc, String name, String value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// new==============================================================================
|
// 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 jsonRead(String& json, String key, String& value) {
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
|||||||
Reference in New Issue
Block a user