File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ The circuit uses an LD1117V33 voltage regulator with two capacitors as specified
1010## Code
1111### Dependencies
1212The mentioned versions are tested, other may work as well but may lead to compile issues.
13- * [ esp8266 v.2.4.2] ( https://github.com/esp8266/Arduino )
14- * [ ArduinoJSON v.5 .13.3 ] ( https://github.com/bblanchon/ArduinoJson )
13+ * [ esp8266 v.2.4.2] ( https://github.com/esp8266/Arduino )
14+ * [ ArduinoJSON v.6 .13.0 ] ( https://github.com/bblanchon/ArduinoJson )
1515
1616### Configuration
1717
Original file line number Diff line number Diff line change @@ -140,13 +140,14 @@ void handleApiRequest() {
140140 */
141141
142142 const size_t bufferSize = JSON_OBJECT_SIZE (3 ) + JSON_OBJECT_SIZE (4 ) + 70 ;
143- DynamicJsonBuffer jsonBuffer (bufferSize);
144- JsonObject& root = jsonBuffer. parseObject ( server.arg (" plain" ));
143+ DynamicJsonDocument jsonDocument (bufferSize);
144+ deserializeJson (jsonDocument, server.arg (" plain" ));
145145
146146 Serial.println (" JSON Body: " );
147- root. printTo ( Serial);
147+ serializeJson (jsonDocument, Serial);
148148 Serial.println ();
149149
150+ JsonObject root = jsonDocument.as <JsonObject>();
150151 const char * state = root[" state" ]; // "ON" or "OFF"
151152 if (strcmp (" OFF" , state) == 0 ) {
152153 Serial.println (" State OFF found: switching off" );
@@ -165,12 +166,12 @@ void handleApiRequest() {
165166
166167 // DEBUG: color
167168 Serial.print (" Color: " );
168- root[" color" ]. printTo ( Serial);
169+ serializeJson ( root[" color" ], Serial);
169170 Serial.println ();
170171
171172 RGB rgb = {0 , 0 , 0 };
172- JsonObject& color = root[" color" ];
173173
174+ JsonObject color = root[" color" ];
174175 // If RGB mode: Parse RGB values
175176 if (color[" mode" ] == " rgb" ) {
176177 // Indeed, the JsonVariant returned by root["..."] has a special implementation of the == operator that knows how to compare string safely.
You can’t perform that action at this time.
0 commit comments