mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 04:32:37 +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:
parent
01ea05d650
commit
0d7482e379
14
src/json.c
14
src/json.c
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user