Fix: skip BOM in JSON files (pin_mapping and config)
This commit is contained in:
parent
3c1d3f7207
commit
993f3213a1
@ -397,6 +397,13 @@ bool ConfigurationClass::read()
|
|||||||
{
|
{
|
||||||
File f = LittleFS.open(CONFIG_FILENAME, "r", false);
|
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;
|
JsonDocument doc;
|
||||||
|
|
||||||
// Deserialize the JSON document
|
// Deserialize the JSON document
|
||||||
|
|||||||
@ -321,6 +321,13 @@ bool PinMappingClass::init(const String& deviceMapping)
|
|||||||
return false;
|
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;
|
JsonDocument doc;
|
||||||
// Deserialize the JSON document
|
// Deserialize the JSON document
|
||||||
DeserializationError error = deserializeJson(doc, f);
|
DeserializationError error = deserializeJson(doc, f);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user