diff --git a/src/Configuration.cpp b/src/Configuration.cpp index db47d9c8a..aefde2c7a 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -160,6 +160,13 @@ bool ConfigurationClass::read() { File f = LittleFS.open(CONFIG_FILENAME, "r", false); + // skip Byte Order Mask (BOM). valid JSON docs always start with '{' or '['. + while (f.available() > 0) { + int c = f.peek(); + if (c == '{' || c == '[') { break; } + f.read(); + } + JsonDocument doc; // Deserialize the JSON document diff --git a/src/PinMapping.cpp b/src/PinMapping.cpp index bd5ea9952..52fff79f7 100644 --- a/src/PinMapping.cpp +++ b/src/PinMapping.cpp @@ -199,6 +199,13 @@ bool PinMappingClass::init(const String& deviceMapping) return false; } + // skip Byte Order Mask (BOM). valid JSON docs always start with '{' or '['. + while (f.available() > 0) { + int c = f.peek(); + if (c == '{' || c == '[') { break; } + f.read(); + } + JsonDocument doc; // Deserialize the JSON document DeserializationError error = deserializeJson(doc, f);