blobmsg_json: let blobmsg_format_json_with_cb with list == true also format arrays
authorFelix Fietkau <nbd@openwrt.org>
Sat, 26 Apr 2014 08:58:54 +0000 (10:58 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 26 Apr 2014 08:59:00 +0000 (10:59 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
blobmsg_json.c

index 3b32b932528ad1f6cfd9b97d5ad3b63d566de260..05779eb8413bed4dbfb3c8818968d8b1670eb83a 100644 (file)
@@ -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);