spa: add spa_json_begin

That combines spa_json_init() and spa_json_next, a common thing to do.
This commit is contained in:
Wim Taymans 2024-09-13 09:22:27 +02:00
parent 08057e0328
commit feccb882b6
7 changed files with 15 additions and 18 deletions

View file

@ -139,8 +139,7 @@ static inline int spa_json_to_pod(struct spa_pod_builder *b, uint32_t flags,
struct spa_json iter;
const char *val;
spa_json_init(&iter, value, len);
if ((len = spa_json_next(&iter, &val)) <= 0)
if ((len = spa_json_begin(&iter, value, len, &val)) <= 0)
return -EINVAL;
return spa_json_to_pod_part(b, flags, info->type, info, &iter, val, len);

View file

@ -356,6 +356,12 @@ static inline bool spa_json_get_error(struct spa_json *iter, const char *start,
return true;
}
static inline int spa_json_begin(struct spa_json * iter, const char *data, size_t size, const char **val)
{
spa_json_init(iter, data, size);
return spa_json_next(iter, val);
}
static inline int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type)
{
const char *value;