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_string
This commit is contained in:
parent
f3e2147e72
commit
790d431624
14
src/json.c
14
src/json.c
@ -398,6 +398,20 @@ bool json_iter_get_container(struct json_iter *iter,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool json_iter_get_string(struct json_iter *iter, char **s)
|
||||
{
|
||||
struct json_contents *c = iter->contents;
|
||||
jsmntok_t *t = c->tokens + iter->current;
|
||||
|
||||
if (t->type != JSMN_STRING)
|
||||
return false;
|
||||
|
||||
if (s)
|
||||
*s = TOK_TO_STR(c->json, t);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum json_type json_iter_get_type(struct json_iter *iter)
|
||||
{
|
||||
struct json_contents *c = iter->contents;
|
||||
|
@ -95,6 +95,7 @@ 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);
|
||||
bool json_iter_get_string(struct json_iter *iter, char **s);
|
||||
|
||||
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