MCPcopy Create free account
hub / github.com/OpenStickCommunity/GP2040-CE / fromJSON

Method fromJSON

src/config_utils.cpp:2476–2499  ·  view source on GitHub ↗

Missing properties are ignored and initialized with default values Type mismatches, buffer overruns or illegal enum values cause an error

Source from the content-addressed store, hash-verified

2474// Missing properties are ignored and initialized with default values
2475// Type mismatches, buffer overruns or illegal enum values cause an error
2476bool 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}

Callers

nothing calls this directly

Calls 4

migrateTurboPinToGpioFunction · 0.85
migrateMacroPinsToGpioFunction · 0.85

Tested by

no test coverage detected