mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-02 07:15:38 -04:00
json: a container start also ends a bare string
This stops the parser from seeing foo{bar as a single string.
This also makes a valid test work, add another small test.
This commit is contained in:
parent
b08cfcb883
commit
2895bd59fe
2 changed files with 8 additions and 1 deletions
|
|
@ -222,7 +222,7 @@ SPA_API_JSON int spa_json_next(struct spa_json * iter, const char **value)
|
||||||
switch (cur) {
|
switch (cur) {
|
||||||
case '\0':
|
case '\0':
|
||||||
case '\t': case ' ': case '\r': case '\n':
|
case '\t': case ' ': case '\r': case '\n':
|
||||||
case '"': case '#':
|
case '"': case '#': case '{': case '[':
|
||||||
case ':': case ',': case '=': case ']': case '}':
|
case ':': case ',': case '=': case ']': case '}':
|
||||||
iter->state = __STRUCT | flag;
|
iter->state = __STRUCT | flag;
|
||||||
if (iter->depth > 0)
|
if (iter->depth > 0)
|
||||||
|
|
|
||||||
|
|
@ -350,6 +350,12 @@ PWTEST(json_parse)
|
||||||
expect_string(&it[0], "hello");
|
expect_string(&it[0], "hello");
|
||||||
expect_end(&it[0]);
|
expect_end(&it[0]);
|
||||||
|
|
||||||
|
json = "xy{}";
|
||||||
|
spa_json_init(&it[0], json, strlen(json));
|
||||||
|
expect_string_or_bare(&it[0], "xy");
|
||||||
|
expect_object(&it[0], &it[1]);
|
||||||
|
expect_end(&it[0]);
|
||||||
|
|
||||||
/* top-level context */
|
/* top-level context */
|
||||||
json = "x y x y";
|
json = "x y x y";
|
||||||
spa_json_init(&it[0], json, strlen(json));
|
spa_json_init(&it[0], json, strlen(json));
|
||||||
|
|
@ -936,6 +942,7 @@ PWTEST(json_data)
|
||||||
"n_array_missing_value.json",
|
"n_array_missing_value.json",
|
||||||
"n_array_number_and_comma.json",
|
"n_array_number_and_comma.json",
|
||||||
"n_array_number_and_several_commas.json",
|
"n_array_number_and_several_commas.json",
|
||||||
|
"n_array_inner_array_no_comma.json",
|
||||||
"n_object_comma_instead_of_colon.json",
|
"n_object_comma_instead_of_colon.json",
|
||||||
"n_object_double_colon.json",
|
"n_object_double_colon.json",
|
||||||
"n_object_missing_semicolon.json",
|
"n_object_missing_semicolon.json",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue