mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-31 13:00:49 +00:00
Fix #1690 - mg_json_get for keys with the same prefix
This commit is contained in:
1 parent
1c16e95b3a
commit
0661f5921a
3 files changed
+11
-2
No files matched your search
@@ -2490,6 +2490,11 @@ static void test_json(void) {
|
||||
ASSERT((str = mg_json_get_hex(json, "$[1]", &len)) != NULL);
|
||||
ASSERT(len == 5 && memcmp(str, "\x01\x00\x02hi", (size_t) len) == 0);
|
||||
free(str);
|
||||
|
||||
json = mg_str("{\"a\":[1,2,3], \"ab\": 2}");
|
||||
ASSERT(mg_json_get_long(json, "$.a[0]", -42) == 1);
|
||||
ASSERT(mg_json_get_long(json, "$.ab", -42) == 2);
|
||||
ASSERT(mg_json_get_long(json, "$.ac", -42) == -42);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user