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:
Wim Taymans 2024-09-13 16:26:36 +02:00
parent cd81b5f39a
commit ce390d5b22
24 changed files with 171 additions and 269 deletions

View file

@ -997,10 +997,7 @@ int servers_create_and_start(struct impl *impl, const char *addresses, struct pw
if (spa_json_is_object(v, len)) {
spa_json_enter(&it[0], &it[1]);
while (spa_json_get_string(&it[1], key, sizeof(key)) > 0) {
if ((len = spa_json_next(&it[1], &v)) <= 0)
break;
while ((len = spa_json_object_next(&it[1], key, sizeof(key), &v)) > 0) {
if (spa_streq(key, "address")) {
spa_json_parse_stringn(v, len, addr_str, sizeof(addr_str));
} else if (spa_streq(key, "max-clients")) {