Missing properties are ignored and initialized with default values Type mismatches, buffer overruns or illegal enum values cause an error
| 2474 | // Missing properties are ignored and initialized with default values |
| 2475 | // Type mismatches, buffer overruns or illegal enum values cause an error |
| 2476 | bool ConfigUtils::fromJSON(Config& config, const char* data, size_t dataLen) |
| 2477 | { |
| 2478 | DynamicJsonDocument doc(1024 * 10); |
| 2479 | if (deserializeJson(doc, data, dataLen) != DeserializationError::Ok || !doc.is<JsonObject>()) |
| 2480 | { |
| 2481 | return false; |
| 2482 | } |
| 2483 | |
| 2484 | // Store config struct on the heap to avoid stack overflow |
| 2485 | if (!fromJSONConfig(doc.as<JsonObjectConst>(), config)) |
| 2486 | { |
| 2487 | return false; |
| 2488 | } |
| 2489 | |
| 2490 | initUnsetPropertiesWithDefaults(config); |
| 2491 | |
| 2492 | // we need to run migrations here too, in case the json document changed pins or things derived from pins |
| 2493 | gpioMappingsMigrationCore(config); |
| 2494 | migrateTurboPinToGpio(config); |
| 2495 | migrateAuthenticationMethods(config); |
| 2496 | migrateMacroPinsToGpio(config); |
| 2497 | |
| 2498 | return true; |
| 2499 | } |
nothing calls this directly
no test coverage detected