Skip to content

Commit

Permalink
fix: update to use array index operator notation (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
evemawrey authored May 8, 2024
1 parent a2c4bc6 commit 258b047
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ void ConfigManager::handleAPPost() {
if (isJson) {
JsonObject obj = decodeJson(server->arg("plain"));

ssid = obj.getMember("ssid").as<String>();
password = obj.getMember("password").as<String>();
ssid = String((const char*)obj["ssid"]);
password = String((const char*)obj["password"]);
} else {
ssid = server->arg("ssid");
password = server->arg("password");
Expand Down
18 changes: 7 additions & 11 deletions src/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,13 @@ class ConfigParameter : public BaseParameter {
void update(T value) { *ptr = value; }

void fromJson(JsonObject* json) {
if (json->containsKey(name) && json->getMember(name).is<T>()) {
this->update(json->getMember(name).as<T>());
const T value = (*json)[name];
if (value) {
this->update(value);
}
}

void toJson(JsonObject* json) {
// json->set(name, *ptr);
json->getOrAddMember(name).set(*ptr);
}
void toJson(JsonObject* json) { (*json)[name] = *ptr; }

void clearData() {
DebugPrint("Clearing: ");
Expand Down Expand Up @@ -121,15 +119,13 @@ class ConfigStringParameter : public BaseParameter {
}

void fromJson(JsonObject* json) {
if (json->containsKey(name) && json->getMember(name).is<const char*>()) {
const char* value = json->getMember(name).as<const char*>();
const char* value = (*json)[name];
if (value) {
this->update(value);
}
}

void toJson(JsonObject* json) {
json->getOrAddMember(name).set((const char*)ptr);
}
void toJson(JsonObject* json) { (*json)[name] = (const char*)ptr; }

void clearData() {
DebugPrint("Clearing: ");
Expand Down

0 comments on commit 258b047

Please sign in to comment.