 
 #if ARDUINOJSON_VERSION_MAJOR == 6
 //#pragma message("Compiling for ArduinoJson v6")
-bool json2patterns(const char* json) {
-  DynamicJsonDocument doc(2000);
+bool json2patterns(String &json) {
+  // in ArduinoJson v6 a DynamicJsonDocument does not expand as needed
+  // like it did in ArduinoJson v5. So rather then try to compute the
+  // optimum heap size, we'll just allocated a bunch of space on the
+  // heap and hope it's enough.
+  int freeHeap = ESP.getFreeHeap();
+  DynamicJsonDocument doc(freeHeap - 3096); // allocate all of the available heap except 3kB
   DeserializationError error = deserializeJson(doc, json);
   if (!error) {
     JsonObject deviceJson = doc.as<JsonObject>();

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

#define VERSION "2.0.8"

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 not rebooting due to catastrophic error, restore pattern data from eeprom
  struct  rst_info  *rstInfo = system_get_rst_info();
  //Serial.print("rstInfo->reason:"); Serial.println(rstInfo->reason);
  if (rstInfo->reason !=  REASON_EXCEPTION_RST) { // not reason 2
    restoreFromEEPROM();
  }
