diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 414704309..03e210ce0 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -806,7 +806,9 @@ static void json_settings(cJSON *json) { else { sprintf(value, "%d", child->valueint); } - config_set(child->string, value); + if (config_get(child->string) == NULL) { + config_set(child->string, value); + } } } } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 950868046..93fcd8d10 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -69,12 +69,15 @@ static void test_settings(CuTest * tc) "\"string\" : \"1d4\"," "\"integer\" : 14," "\"true\": true," + "\"game.id\": 4," "\"false\": false," "\"float\" : 1.5 }}"; cJSON *json = cJSON_Parse(data); test_cleanup(); + config_set("game.id", "42"); // should not be replaced json_config(json); + CuAssertStrEquals(tc, "42", config_get("game.id")); CuAssertStrEquals(tc, "1", config_get("true")); CuAssertStrEquals(tc, "0", config_get("false")); CuAssertStrEquals(tc, "1d4", config_get("string"));