Fixed a problem that losing the value with loadMember

pull/41/head
Hieromon Ikasamo 6 years ago
parent 02dc8f292d
commit 34a0d45b73
  1. 19
      src/AutoConnectElementJsonImpl.h

@ -60,6 +60,7 @@ void AutoConnectElementJson::_serialize(JsonObject& json) {
*/ */
void AutoConnectElementJson::_setMember(const JsonObject& json) { void AutoConnectElementJson::_setMember(const JsonObject& json) {
name = json.get<String>(F(AUTOCONNECT_JSON_KEY_NAME)); name = json.get<String>(F(AUTOCONNECT_JSON_KEY_NAME));
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_VALUE)))
value = json.get<String>(F(AUTOCONNECT_JSON_KEY_VALUE)); value = json.get<String>(F(AUTOCONNECT_JSON_KEY_VALUE));
} }
@ -81,6 +82,7 @@ bool AutoConnectButtonJson::loadMember(const JsonObject& json) {
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE));
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACBUTTON))) { if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACBUTTON))) {
_setMember(json); _setMember(json);
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_ACTION)))
action = json.get<String>(F(AUTOCONNECT_JSON_KEY_ACTION)); action = json.get<String>(F(AUTOCONNECT_JSON_KEY_ACTION));
return true; return true;
} }
@ -116,7 +118,9 @@ bool AutoConnectCheckboxJson::loadMember(const JsonObject& json) {
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE));
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACCHECKBOX))) { if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACCHECKBOX))) {
_setMember(json); _setMember(json);
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_LABEL)))
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL));
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_CHECKED)))
checked = json.get<bool>(F(AUTOCONNECT_JSON_KEY_CHECKED)); checked = json.get<bool>(F(AUTOCONNECT_JSON_KEY_CHECKED));
return true; return true;
} }
@ -154,8 +158,11 @@ bool AutoConnectInputJson::loadMember(const JsonObject& json) {
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE));
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACINPUT))) { if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACINPUT))) {
_setMember(json); _setMember(json);
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_LABEL)))
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL));
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_PATTERN)))
pattern = json.get<String>(F(AUTOCONNECT_JSON_KEY_PATTERN)); pattern = json.get<String>(F(AUTOCONNECT_JSON_KEY_PATTERN));
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_PLACEHOLDER)))
placeholder = json.get<String>(F(AUTOCONNECT_JSON_KEY_PLACEHOLDER)); placeholder = json.get<String>(F(AUTOCONNECT_JSON_KEY_PLACEHOLDER));
return true; return true;
} }
@ -193,17 +200,23 @@ bool AutoConnectRadioJson::loadMember(const JsonObject& json) {
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE));
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACRADIO))) { if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACRADIO))) {
_setMember(json); _setMember(json);
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_LABEL)))
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL));
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_CHECKED)))
checked = static_cast<uint8_t>(json.get<int>(F(AUTOCONNECT_JSON_KEY_CHECKED))); checked = static_cast<uint8_t>(json.get<int>(F(AUTOCONNECT_JSON_KEY_CHECKED)));
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_ARRANGE))) {
String arrange = json.get<String>(F(AUTOCONNECT_JSON_KEY_ARRANGE)); String arrange = json.get<String>(F(AUTOCONNECT_JSON_KEY_ARRANGE));
if (arrange.equalsIgnoreCase(F(AUTOCONNECT_JSON_KEY_VERTICAL))) if (arrange.equalsIgnoreCase(F(AUTOCONNECT_JSON_KEY_VERTICAL)))
order = AC_Vertical; order = AC_Vertical;
else if (arrange.equalsIgnoreCase(F(AUTOCONNECT_JSON_KEY_HORIZONTAL))) else if (arrange.equalsIgnoreCase(F(AUTOCONNECT_JSON_KEY_HORIZONTAL)))
order = AC_Horizontal; order = AC_Horizontal;
}
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_VALUE))) {
empty(); empty();
JsonArray& optionArray = json[AUTOCONNECT_JSON_KEY_VALUE]; JsonArray& optionArray = json[AUTOCONNECT_JSON_KEY_VALUE];
for (auto value : optionArray) for (auto value : optionArray)
add(value.as<String>()); add(value.as<String>());
}
return true; return true;
} }
return false; return false;
@ -249,13 +262,17 @@ bool AutoConnectSelectJson::loadMember(const JsonObject& json) {
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE));
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))) {
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL));
}
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_OPTION))) {
empty(); empty();
JsonArray& optionArray = json[AUTOCONNECT_JSON_KEY_OPTION]; JsonArray& optionArray = json[AUTOCONNECT_JSON_KEY_OPTION];
for (auto value : optionArray) for (auto value : optionArray)
add(value.as<String>()); add(value.as<String>());
return true; return true;
} }
}
return false; return false;
} }
@ -290,6 +307,7 @@ bool AutoConnectSubmitJson::loadMember(const JsonObject& json) {
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE));
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACSUBMIT))) { if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACSUBMIT))) {
_setMember(json); _setMember(json);
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_URI)))
uri = json.get<String>(F(AUTOCONNECT_JSON_KEY_URI)); uri = json.get<String>(F(AUTOCONNECT_JSON_KEY_URI));
return true; return true;
} }
@ -325,6 +343,7 @@ bool AutoConnectTextJson::loadMember(const JsonObject& json) {
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE));
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACTEXT))) { if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACTEXT))) {
_setMember(json); _setMember(json);
if (json.containsKey(F(AUTOCONNECT_JSON_KEY_STYLE)))
style = json.get<String>(F(AUTOCONNECT_JSON_KEY_STYLE)); style = json.get<String>(F(AUTOCONNECT_JSON_KEY_STYLE));
return true; return true;
} }

Loading…
Cancel
Save