fix json list parsing

This commit is contained in:
Felix Fietkau 2011-01-30 01:13:32 +01:00
parent 2d9f917d00
commit ff585b97c0
3 changed files with 4 additions and 4 deletions

View file

@ -155,7 +155,7 @@ static void blobmsg_format_json_list(struct strbuf *s, struct blob_attr *attr, i
blobmsg_puts(s, (array ? " ]" : " }"), 2); 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; struct strbuf s;
@ -163,7 +163,7 @@ char *blobmsg_format_json(struct blob_attr *attr)
s.buf = malloc(s.len); s.buf = malloc(s.len);
s.pos = 0; 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) if (!s.len)
return NULL; return NULL;

View file

@ -139,7 +139,7 @@ static inline int blobmsg_buf_init(struct blob_buf *buf)
return blob_buf_init(buf, BLOBMSG_TYPE_TABLE); 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) \ #define blobmsg_for_each_attr(pos, attr, rem) \
for (rem = blobmsg_data_len(attr), pos = blobmsg_data(attr); \ for (rem = blobmsg_data_len(attr), pos = blobmsg_data(attr); \

View file

@ -128,7 +128,7 @@ int main(int argc, char **argv)
blobmsg_buf_init(&buf); blobmsg_buf_init(&buf);
fill_message(&buf); fill_message(&buf);
dump_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) if (buf.buf)
free(buf.buf); free(buf.buf);