Skip to content

Commit 91333c5

Browse files
committed
Fix json export for typed parameters.
1 parent d253c19 commit 91333c5

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/IotWebConfTParameter.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@ class ConfigItemBridge : public ConfigItem
5353
out->println("'");
5454
}
5555

56+
#ifdef IOTWEBCONF_ENABLE_JSON
57+
void loadFromJson(JsonObject jsonObject)
58+
{
59+
if (jsonObject.containsKey(this->getId()))
60+
{
61+
# ifdef IOTWEBCONF_DEBUG_TO_SERIAL
62+
Serial.print(F("Applying value from JSON for parameterId: "));
63+
Serial.println(this->getId());
64+
# endif
65+
const char* value = jsonObject[this->getId()];
66+
this->update(String(value));
67+
}
68+
else
69+
{
70+
# ifdef IOTWEBCONF_DEBUG_TO_SERIAL
71+
Serial.print(F("No value found in JSON for parameterId: "));
72+
Serial.println(this->getId());
73+
# endif
74+
}
75+
}
76+
#endif
77+
5678
protected:
5779
ConfigItemBridge(const char* id) : ConfigItem(id) { }
5880
virtual int getInputLength() { return 0; };

0 commit comments

Comments
 (0)