mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
spa: add spa_json_object_next
This gets the next key and value from an object. This function is better because it will skip key/value pairs that don't fit in the array to hold the key. The previous code patter would stop parsing the object as soon as a key larger than the available space was found.
This commit is contained in:
parent
cd81b5f39a
commit
ce390d5b22
24 changed files with 171 additions and 269 deletions
|
|
@ -1126,11 +1126,8 @@ static void json_dump_val(struct data *d, const char *key, struct spa_json *it,
|
|||
char val[1024];
|
||||
put_begin(d, key, "{", STATE_SIMPLE);
|
||||
spa_json_enter(it, &sub);
|
||||
while (spa_json_get_string(&sub, val, sizeof(val)) > 0) {
|
||||
if ((len = spa_json_next(&sub, &value)) <= 0)
|
||||
break;
|
||||
while ((len = spa_json_object_next(&sub, val, sizeof(val), &value)) > 0)
|
||||
json_dump_val(d, val, &sub, value, len);
|
||||
}
|
||||
put_end(d, "}", STATE_SIMPLE);
|
||||
} else if (spa_json_is_string(value, len)) {
|
||||
put_encoded_string(d, key, strndupa(value, len));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue