This commit is contained in:
cpq committed 2026-05-20 07:26:13 +01:00
1 parent 04ca25e4d8
commit b773e33f4e
3 files changed
+15 -5

No files matched your search

+11 -1
View File
@@ -3565,13 +3565,23 @@ static void test_json(void) {
int len;
char *str = NULL;
json = mg_str("{\"a\":\"b\"}");
json = mg_str("{\"a\":\"b\", \"c\":\"\"}");
str = mg_json_get_str(json, "$.a");
ASSERT(str != NULL);
// printf("---> [%s]\n", str);
ASSERT(strcmp(str, "b") == 0);
mg_free(str);
// Non existent string
str = mg_json_get_str(json, "$.d");
ASSERT(str == NULL);
// Empty string
str = mg_json_get_str(json, "$.c");
ASSERT(str != NULL);
ASSERT(strcmp(str, "") == 0);
mg_free(str);
json = mg_str("{\"a\": \"hi\\nthere\",\"b\": [12345, true]}");
str = mg_json_get_str(json, "$.a");