--- a/test/json.c Sun Jan 04 17:45:50 2026 +0100 +++ b/test/json.c Sun Jan 04 18:09:59 2026 +0100 @@ -381,3 +381,37 @@ free(obj); } } + +CX_TEST(testJsonToObjectWithArray) { + const char *jsonStr = + "{" + "\"test\":\"hello world\"," + "\"test2List\":[ {\"name\":\"elm0\", \"i\":0}, {\"name\":\"elm1\", \"i\":1} ]" + "}"; + + CxJsonValue *json; + cxJsonFromString(NULL, jsonStr, &json); + + CX_TEST_DO { + Test5 *obj = dbuJsonToObject(test5_class, NULL, json); + + CX_TEST_ASSERT(obj); + CX_TEST_ASSERT(!cx_strcmp(obj->test, "hello world")); + CX_TEST_ASSERT(obj->test2List); + CX_TEST_ASSERT(cxListSize(obj->test2List) == 2); + + Test2 *elm0 = cxListAt(obj->test2List, 0); + Test2 *elm1 = cxListAt(obj->test2List, 1); + + CX_TEST_ASSERT(elm0); + CX_TEST_ASSERT(elm1); + + CX_TEST_ASSERT(!cx_strcmp(elm0->name, "elm0")); + CX_TEST_ASSERT(elm0->i == 0); + + CX_TEST_ASSERT(!cx_strcmp(elm1->name, "elm1")); + CX_TEST_ASSERT(elm1->i == 1); + + free(obj); + } +}