     String data = server.arg("plain");
     Serial.println(data);
 
-    json2patterns(data.c_str());
-    if (numPatterns > 0) {
+    bool isParseOk = json2patterns(data.c_str());
+
+    if (isParseOk && numPatterns > 0) {
       ws2812fx.stop();
       ws2812fx.clear();
       ws2812fx.resetSegments();

#include <EEPROM.h>
#include <ArduinoOTA.h>

#define VERSION "2.0.7"

uint8_t  dataPin = D1; // default digital pin used to drive the LED strip
uint16_t numLeds = 30; // default number of LEDs on the strip

        if (numPatterns >= MAX_NUM_PATTERNS) break;
      }
    } else {
      Serial.println(F("JSON contains no pattern data"));
      return false;
    }
  } else {
    Serial.println(F("Could not parse JSON payload"));
    return false;
  }
  return true;
}
#endif

#if ARDUINOJSON_VERSION_MAJOR == 6
//#pragma message("Compiling for ArduinoJson v6")
bool json2patterns(const char* json) {
  DynamicJsonDocument doc(2000);
  DeserializationError error = deserializeJson(doc, json);
  if (!error) {
    JsonObject deviceJson = doc.as<JsonObject>();
