From 9c58f3bc556de6a33ba4c7cf2f32ec2b54d1b236 Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Sun, 28 Apr 2019 04:32:44 +0900 Subject: [PATCH] Fix losing selection options. (Issue #64) --- src/AutoConnectElementJsonImpl.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/AutoConnectElementJsonImpl.h b/src/AutoConnectElementJsonImpl.h index 762950e..fd03913 100644 --- a/src/AutoConnectElementJsonImpl.h +++ b/src/AutoConnectElementJsonImpl.h @@ -346,18 +346,17 @@ bool AutoConnectSelectJson::loadMember(const JsonObject& json) { String type = json[F(AUTOCONNECT_JSON_KEY_TYPE)].as(); if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACSELECT))) { _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(); - } if (json.containsKey(F(AUTOCONNECT_JSON_KEY_OPTION))) { empty(); ArduinoJsonArray optionArray = json[AUTOCONNECT_JSON_KEY_OPTION]; for (auto value : optionArray) add(value.as()); + if (json.containsKey(F(AUTOCONNECT_JSON_KEY_SELECTED))) + selected = static_cast(json[F(AUTOCONNECT_JSON_KEY_SELECTED)].as()); return true; } - if (json.containsKey(F(AUTOCONNECT_JSON_KEY_SELECTED))) - selected = static_cast(json[F(AUTOCONNECT_JSON_KEY_SELECTED)].as()); } return false; }