* [PATCH v2 1/5] json: add json_iter_get_string
@ 2022-01-06 22:52 James Prestwood
0 siblings, 0 replies; 2+ messages in thread
From: James Prestwood @ 2022-01-06 22:52 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]
---
src/json.c | 14 ++++++++++++++
src/json.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/src/json.c b/src/json.c
index b48dba4a..b89fbaa6 100644
--- a/src/json.c
+++ b/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;
diff --git a/src/json.h b/src/json.h
index 518d778c..1db3428d 100644
--- a/src/json.h
+++ b/src/json.h
@@ -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);
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2 1/5] json: add json_iter_get_string
@ 2022-01-06 22:43 Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2022-01-06 22:43 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 207 bytes --]
Hi James,
On 1/6/22 16:52, James Prestwood wrote:
> ---
> src/json.c | 14 ++++++++++++++
> src/json.h | 1 +
> 2 files changed, 15 insertions(+)
>
All applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-06 22:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-06 22:52 [PATCH v2 1/5] json: add json_iter_get_string James Prestwood
-- strict thread matches above, loose matches on Subject: below --
2022-01-06 22:43 Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox