Fix losing selection options. (Issue #64)

pull/66/head
Hieromon Ikasamo 6 years ago
parent a447518c70
commit 9c58f3bc55
  1. 7
      src/AutoConnectElementJsonImpl.h

@ -346,18 +346,17 @@ bool AutoConnectSelectJson::loadMember(const JsonObject& json) {
String type = json[F(AUTOCONNECT_JSON_KEY_TYPE)].as<String>(); String type = json[F(AUTOCONNECT_JSON_KEY_TYPE)].as<String>();
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACSELECT))) { if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACSELECT))) {
_setMember(json); _setMember(json);
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_LABEL))) { if (json.containsKey(F(AUTOCONNECT_JSON_KEY_LABEL)))
label = json[F(AUTOCONNECT_JSON_KEY_LABEL)].as<String>(); label = json[F(AUTOCONNECT_JSON_KEY_LABEL)].as<String>();
}
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_OPTION))) { if (json.containsKey(F(AUTOCONNECT_JSON_KEY_OPTION))) {
empty(); empty();
ArduinoJsonArray optionArray = json[AUTOCONNECT_JSON_KEY_OPTION]; ArduinoJsonArray optionArray = json[AUTOCONNECT_JSON_KEY_OPTION];
for (auto value : optionArray) for (auto value : optionArray)
add(value.as<String>()); add(value.as<String>());
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_SELECTED)))
selected = static_cast<uint8_t>(json[F(AUTOCONNECT_JSON_KEY_SELECTED)].as<int>());
return true; return true;
} }
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_SELECTED)))
selected = static_cast<uint8_t>(json[F(AUTOCONNECT_JSON_KEY_SELECTED)].as<int>());
} }
return false; return false;
} }

Loading…
Cancel
Save