3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-21 22:09:23 +01:00

json: add json_iter_get_container

This allows getting an iterator for a container nested inside
an array.
This commit is contained in:
James Prestwood 2022-01-06 11:50:05 -08:00 committed by Denis Kenzior
parent 01ea05d650
commit 0d7482e379
2 changed files with 16 additions and 0 deletions

View File

@ -384,6 +384,20 @@ bool json_iter_get_null(struct json_iter *iter)
return false;
}
bool json_iter_get_container(struct json_iter *iter,
struct json_iter *container)
{
struct json_contents *c = iter->contents;
jsmntok_t *t = c->tokens + iter->current;
if (t->type != JSMN_OBJECT && t->type != JSMN_ARRAY)
return false;
iter_recurse(iter, t, container);
return true;
}
enum json_type json_iter_get_type(struct json_iter *iter)
{
struct json_contents *c = iter->contents;

View File

@ -93,6 +93,8 @@ bool json_iter_get_int(struct json_iter *iter, int *i);
bool json_iter_get_uint(struct json_iter *iter, unsigned int *i);
bool json_iter_get_boolean(struct json_iter *iter, bool *b);
bool json_iter_get_null(struct json_iter *iter);
bool json_iter_get_container(struct json_iter *iter,
struct json_iter *container);
enum json_type json_iter_get_type(struct json_iter *iter);
bool json_iter_next(struct json_iter *iter);