From 131b3352d9005895fdd6b1c9fb9cb1263469773b Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 26 Apr 2014 10:58:54 +0200 Subject: [PATCH] blobmsg_json: let blobmsg_format_json_with_cb with list == true also format arrays Signed-off-by: Felix Fietkau --- blobmsg_json.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blobmsg_json.c b/blobmsg_json.c index 3b32b93..05779eb 100644 --- a/blobmsg_json.c +++ b/blobmsg_json.c @@ -286,6 +286,7 @@ static void blobmsg_format_json_list(struct strbuf *s, struct blob_attr *attr, i char *blobmsg_format_json_with_cb(struct blob_attr *attr, bool list, blobmsg_json_format_t cb, void *priv, int indent) { struct strbuf s; + bool array; s.len = blob_len(attr); s.buf = malloc(s.len); @@ -299,8 +300,11 @@ char *blobmsg_format_json_with_cb(struct blob_attr *attr, bool list, blobmsg_jso s.indent_level = indent; } + array = blob_is_extended(attr) && + blobmsg_type(attr) == BLOBMSG_TYPE_ARRAY; + if (list) - blobmsg_format_json_list(&s, blobmsg_data(attr), blobmsg_data_len(attr), false); + blobmsg_format_json_list(&s, blobmsg_data(attr), blobmsg_data_len(attr), array); else blobmsg_format_element(&s, attr, false, false);