void *data;
int len;
- if (!array) {
+ if (!array && blobmsg_name(attr)[0]) {
blobmsg_format_string(s, blobmsg_name(attr));
blobmsg_puts(s, ":", 1);
}
blobmsg_puts(s, (array ? " ]" : " }"), 2);
}
-char *blobmsg_format_json(struct blob_attr *attr, bool named)
+char *blobmsg_format_json(struct blob_attr *attr, bool list)
{
struct strbuf s;
s.buf = malloc(s.len);
s.pos = 0;
- blobmsg_format_json_list(&s, blob_data(attr), blob_len(attr), !named);
+ if (list)
+ blobmsg_format_json_list(&s, blob_data(attr), blob_len(attr), false);
+ else
+ blobmsg_format_element(&s, attr, false, false);
if (!s.len)
return NULL;
return BLOBMSG_PADDING(sizeof(struct blobmsg_hdr) + namelen + 1);
}
-static inline void *blobmsg_name(struct blob_attr *attr)
+static inline char *blobmsg_name(struct blob_attr *attr)
{
struct blobmsg_hdr *hdr = blob_data(attr);
- return &hdr->name;
+ return (char *) hdr->name;
}
static inline void *blobmsg_data(struct blob_attr *attr)
return blob_buf_init(buf, BLOBMSG_TYPE_TABLE);
}
-char *blobmsg_format_json(struct blob_attr *attr, bool named);
+char *blobmsg_format_json(struct blob_attr *attr, bool list);
#define blobmsg_for_each_attr(pos, attr, rem) \
for (rem = blobmsg_data_len(attr), pos = blobmsg_data(attr); \