| 422 | } |
| 423 | |
| 424 | bool DisplayManager_::parseCustomPage(const String &name, const char *json, bool preventSave) |
| 425 | { |
| 426 | if ((strcmp(json, "") == 0) || (strcmp(json, "{}") == 0)) |
| 427 | { |
| 428 | removeCustomAppFromApps(name, true); |
| 429 | return true; |
| 430 | } |
| 431 | |
| 432 | DynamicJsonDocument doc(8192); |
| 433 | DeserializationError error = deserializeJson(doc, json); |
| 434 | if (error) |
| 435 | { |
| 436 | DEBUG_PRINTLN(error.c_str()); |
| 437 | doc.clear(); |
| 438 | return false; |
| 439 | } |
| 440 | |
| 441 | if (doc.is<JsonObject>()) |
| 442 | { |
| 443 | JsonObject rootObj = doc.as<JsonObject>(); |
| 444 | return generateCustomPage(name, rootObj, preventSave); |
| 445 | } |
| 446 | else if (doc.is<JsonArray>()) |
| 447 | { |
| 448 | JsonArray customPagesArray = doc.as<JsonArray>(); |
| 449 | int cpIndex = 0; |
| 450 | for (JsonObject customPageObject : customPagesArray) |
| 451 | { |
| 452 | generateCustomPage(name + String(cpIndex), customPageObject, preventSave); |
| 453 | ++cpIndex; |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | doc.clear(); |
| 458 | return true; |
| 459 | } |
| 460 | |
| 461 | // Function to subscribe to MQTT topics based on placeholders in text |
| 462 | void subscribeToPlaceholders(String text) |
no test coverage detected