diff --git a/include/Utils/JsonUtils.h b/include/Utils/JsonUtils.h index 51c73b34..cbcf38d1 100644 --- a/include/Utils/JsonUtils.h +++ b/include/Utils/JsonUtils.h @@ -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, int& value); -bool jsonWrite(String& json, String name, String value); -bool jsonWrite(String& json, String name, bool value); -bool jsonWrite(String& json, String name, int value); -bool jsonWrite(String& json, String name, float value); +bool jsonWriteStr_(String& json, String name, String value); +bool jsonWriteBool_(String& json, String name, bool value); +bool jsonWriteInt_(String& json, String name, int value); +bool jsonWriteFloat_(String& json, String name, float value); void saveConfig(); void saveStore(); \ No newline at end of file diff --git a/src/Utils/JsonUtils.cpp b/src/Utils/JsonUtils.cpp index fd235119..d30fab20 100644 --- a/src/Utils/JsonUtils.cpp +++ b/src/Utils/JsonUtils.cpp @@ -114,7 +114,7 @@ String jsonWriteFloat(String& json, String name, float value) { } //new============================================================================== -bool jsonWrite(String& json, String name, String value) { +bool jsonWriteStr_(String& json, String key, String value) { bool ret = true; DynamicJsonDocument doc(JSON_BUFFER_SIZE); DeserializationError error = deserializeJson(doc, json); @@ -122,13 +122,13 @@ bool jsonWrite(String& json, String name, String value) { SerialPrint("EE", F("jsonWrite"), error.f_str()); ret = false; } - doc[name] = value; + doc[key] = value; json = ""; serializeJson(doc, json); return ret; } -bool jsonWrite(String& json, String name, bool value) { +bool jsonWriteBool_(String& json, String key, bool value) { bool ret = true; DynamicJsonDocument doc(JSON_BUFFER_SIZE); DeserializationError error = deserializeJson(doc, json); @@ -136,13 +136,13 @@ bool jsonWrite(String& json, String name, bool value) { SerialPrint("EE", F("jsonWrite"), error.f_str()); ret = false; } - doc[name] = value; + doc[key] = value; json = ""; serializeJson(doc, json); return ret; } -bool jsonWrite(String& json, String name, int value) { +bool jsonWriteInt_(String& json, String key, int value) { bool ret = true; DynamicJsonDocument doc(JSON_BUFFER_SIZE); DeserializationError error = deserializeJson(doc, json); @@ -150,13 +150,13 @@ bool jsonWrite(String& json, String name, int value) { SerialPrint("EE", F("jsonWrite"), error.f_str()); ret = false; } - doc[name] = value; + doc[key] = value; json = ""; serializeJson(doc, json); return ret; } -bool jsonWrite(String& json, String name, float value) { +bool jsonWriteFloat_(String& json, String key, float value) { bool ret = true; DynamicJsonDocument doc(JSON_BUFFER_SIZE); DeserializationError error = deserializeJson(doc, json); @@ -164,7 +164,7 @@ bool jsonWrite(String& json, String name, float value) { SerialPrint("EE", F("jsonWrite"), error.f_str()); ret = false; } - doc[name] = value; + doc[key] = value; json = ""; serializeJson(doc, json); return ret; diff --git a/src/main.cpp b/src/main.cpp index d86749a2..ef04e887 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -92,7 +92,7 @@ void setup() { Serial.println(configSetupJson.length()); Serial.println(F("--------------------------------------")); - if (jsonWrite(configSetupJson, "name", "test value")) { + if (jsonWriteStr_(configSetupJson, "name", "test value")) { Serial.println("write sucsess"); }