From: Felix Fietkau Date: Sat, 26 Apr 2014 08:58:54 +0000 (+0200) Subject: blobmsg_json: let blobmsg_format_json_with_cb with list == true also format arrays X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=131b3352d9005895fdd6b1c9fb9cb1263469773b;p=oweals%2Flibubox.git blobmsg_json: let blobmsg_format_json_with_cb with list == true also format arrays Signed-off-by: Felix Fietkau --- 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);