From ff585b97c0b061d3ef7a026a331fa0079e0a7d94 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 30 Jan 2011 01:13:32 +0100 Subject: [PATCH] fix json list parsing --- blobmsg.c | 4 ++-- blobmsg.h | 2 +- examples/blobmsg-example.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/blobmsg.c b/blobmsg.c index bdc5ef7..69a160b 100644 --- a/blobmsg.c +++ b/blobmsg.c @@ -155,7 +155,7 @@ static void blobmsg_format_json_list(struct strbuf *s, struct blob_attr *attr, i blobmsg_puts(s, (array ? " ]" : " }"), 2); } -char *blobmsg_format_json(struct blob_attr *attr) +char *blobmsg_format_json(struct blob_attr *attr, bool named) { struct strbuf s; @@ -163,7 +163,7 @@ char *blobmsg_format_json(struct blob_attr *attr) s.buf = malloc(s.len); s.pos = 0; - blobmsg_format_element(&s, attr, true, true); + blobmsg_format_json_list(&s, blob_data(attr), blob_len(attr), !named); if (!s.len) return NULL; diff --git a/blobmsg.h b/blobmsg.h index aa1f314..554bed8 100644 --- a/blobmsg.h +++ b/blobmsg.h @@ -139,7 +139,7 @@ static inline int blobmsg_buf_init(struct blob_buf *buf) return blob_buf_init(buf, BLOBMSG_TYPE_TABLE); } -char *blobmsg_format_json(struct blob_attr *attr); +char *blobmsg_format_json(struct blob_attr *attr, bool named); #define blobmsg_for_each_attr(pos, attr, rem) \ for (rem = blobmsg_data_len(attr), pos = blobmsg_data(attr); \ diff --git a/examples/blobmsg-example.c b/examples/blobmsg-example.c index 3630208..86762d8 100644 --- a/examples/blobmsg-example.c +++ b/examples/blobmsg-example.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) blobmsg_buf_init(&buf); fill_message(&buf); dump_message(&buf); - fprintf(stderr, "json: %s\n", blobmsg_format_json(buf.head)); + fprintf(stderr, "json: %s\n", blobmsg_format_json(buf.head, false), true); if (buf.buf) free(buf.buf); -- 2.30.2