test completed - working

This commit is contained in:
Dmitry Borisenko
2021-10-09 19:49:43 +00:00
parent 752e09a71d
commit 2e04a980cc
3 changed files with 13 additions and 13 deletions

View File

@@ -15,10 +15,10 @@ bool jsonRead(String& json, String key, String& value);
bool jsonRead(String& json, String key, bool& value); bool jsonRead(String& json, String key, bool& value);
bool jsonRead(String& json, String key, int& value); bool jsonRead(String& json, String key, int& value);
bool jsonWrite(String& json, String name, String value); bool jsonWriteStr_(String& json, String name, String value);
bool jsonWrite(String& json, String name, bool value); bool jsonWriteBool_(String& json, String name, bool value);
bool jsonWrite(String& json, String name, int value); bool jsonWriteInt_(String& json, String name, int value);
bool jsonWrite(String& json, String name, float value); bool jsonWriteFloat_(String& json, String name, float value);
void saveConfig(); void saveConfig();
void saveStore(); void saveStore();

View File

@@ -114,7 +114,7 @@ String jsonWriteFloat(String& json, String name, float value) {
} }
//new============================================================================== //new==============================================================================
bool jsonWrite(String& json, String name, String value) { bool jsonWriteStr_(String& json, String key, String value) {
bool ret = true; bool ret = true;
DynamicJsonDocument doc(JSON_BUFFER_SIZE); DynamicJsonDocument doc(JSON_BUFFER_SIZE);
DeserializationError error = deserializeJson(doc, json); DeserializationError error = deserializeJson(doc, json);
@@ -122,13 +122,13 @@ bool jsonWrite(String& json, String name, String value) {
SerialPrint("EE", F("jsonWrite"), error.f_str()); SerialPrint("EE", F("jsonWrite"), error.f_str());
ret = false; ret = false;
} }
doc[name] = value; doc[key] = value;
json = ""; json = "";
serializeJson(doc, json); serializeJson(doc, json);
return ret; return ret;
} }
bool jsonWrite(String& json, String name, bool value) { bool jsonWriteBool_(String& json, String key, bool value) {
bool ret = true; bool ret = true;
DynamicJsonDocument doc(JSON_BUFFER_SIZE); DynamicJsonDocument doc(JSON_BUFFER_SIZE);
DeserializationError error = deserializeJson(doc, json); DeserializationError error = deserializeJson(doc, json);
@@ -136,13 +136,13 @@ bool jsonWrite(String& json, String name, bool value) {
SerialPrint("EE", F("jsonWrite"), error.f_str()); SerialPrint("EE", F("jsonWrite"), error.f_str());
ret = false; ret = false;
} }
doc[name] = value; doc[key] = value;
json = ""; json = "";
serializeJson(doc, json); serializeJson(doc, json);
return ret; return ret;
} }
bool jsonWrite(String& json, String name, int value) { bool jsonWriteInt_(String& json, String key, int value) {
bool ret = true; bool ret = true;
DynamicJsonDocument doc(JSON_BUFFER_SIZE); DynamicJsonDocument doc(JSON_BUFFER_SIZE);
DeserializationError error = deserializeJson(doc, json); DeserializationError error = deserializeJson(doc, json);
@@ -150,13 +150,13 @@ bool jsonWrite(String& json, String name, int value) {
SerialPrint("EE", F("jsonWrite"), error.f_str()); SerialPrint("EE", F("jsonWrite"), error.f_str());
ret = false; ret = false;
} }
doc[name] = value; doc[key] = value;
json = ""; json = "";
serializeJson(doc, json); serializeJson(doc, json);
return ret; return ret;
} }
bool jsonWrite(String& json, String name, float value) { bool jsonWriteFloat_(String& json, String key, float value) {
bool ret = true; bool ret = true;
DynamicJsonDocument doc(JSON_BUFFER_SIZE); DynamicJsonDocument doc(JSON_BUFFER_SIZE);
DeserializationError error = deserializeJson(doc, json); DeserializationError error = deserializeJson(doc, json);
@@ -164,7 +164,7 @@ bool jsonWrite(String& json, String name, float value) {
SerialPrint("EE", F("jsonWrite"), error.f_str()); SerialPrint("EE", F("jsonWrite"), error.f_str());
ret = false; ret = false;
} }
doc[name] = value; doc[key] = value;
json = ""; json = "";
serializeJson(doc, json); serializeJson(doc, json);
return ret; return ret;

View File

@@ -92,7 +92,7 @@ void setup() {
Serial.println(configSetupJson.length()); Serial.println(configSetupJson.length());
Serial.println(F("--------------------------------------")); Serial.println(F("--------------------------------------"));
if (jsonWrite(configSetupJson, "name", "test value")) { if (jsonWriteStr_(configSetupJson, "name", "test value")) {
Serial.println("write sucsess"); Serial.println("write sucsess");
} }