From 2d3b907128e00b1384484c0bd96591db3f4c3c90 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Wed, 23 Jul 2025 14:46:07 +0200 Subject: test(json): Much more complex json --- test_json.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test_json.c') diff --git a/test_json.c b/test_json.c index 7243a34..a37996c 100644 --- a/test_json.c +++ b/test_json.c @@ -167,3 +167,41 @@ i32 test_json_nested_object() { t_assert(lvl_2.type == JSON_OBJECT); return 0; } + +i32 test_json_complex_multiline() { + Arena perm = Arena_new(128e3); + JSON doc = + JSON_parse(&perm, "{\n" + " \"id\": 819228,\n" + " \"username\": \"rCrRv4PRnUNuAy\",\n" + " \"email\": \"xzbwrzj@zwod.com\",\n" + " \"first_name\": \"4WH7g7PsOEm5\",\n" + " \"last_name\": \"6ulndxUgjbIayl\",\n" + " \"age\": 30,\n" + " \"phone\": \"+1-529-712-3931\",\n" + " \"is_active\": false,\n" + " \"balance\": 9347.49,\n" + " \"tags\": [\n" + " \"TWvZi0\",\n" + " \"pM0TPv9X\"\n" + " ],\n" + " \"metadata\": {\n" + " \"last_login\": \"2024-06-13T21:22:32Z\",\n" + " \"login_count\": 245,\n" + " \"preferences\": {\n" + " \"theme\": \"auto\",\n" + " \"notifications\": true,\n" + " \"language\": \"en\"\n" + " }\n" + " }\n" + " }"); + + JSON id = *JSONObject_get(doc.as.object, S("id")); + t_assert(id.as.integer == 819228); + JSON metadata = *JSONObject_get(doc.as.object, S("metadata")); + JSON preferences = *JSONObject_get(metadata.as.object, S("preferences")); + JSON theme = *JSONObject_get(preferences.as.object, S("theme")); + t_assert(Str_equals(theme.as.string, S("auto"))); + + return 0; +} -- cgit v1.3