utils: add little-endian swap helpers
[project/libubox.git] / blobmsg_json.c
index badf87e..f166358 100644 (file)
@@ -16,7 +16,7 @@
 #include "blobmsg.h"
 #include "blobmsg_json.h"
 
-static bool blobmsg_add_object(struct blob_buf *b, json_object *obj)
+bool blobmsg_add_object(struct blob_buf *b, json_object *obj)
 {
        json_object_object_foreach(obj, key, val) {
                if (!blobmsg_add_json_element(b, key, val))
@@ -108,7 +108,7 @@ static bool blobmsg_puts(struct strbuf *s, const char *c, int len)
                return true;
 
        if (s->pos + len >= s->len) {
-               s->len += 16;
+               s->len += 16 + len;
                s->buf = realloc(s->buf, s->len);
                if (!s->buf)
                        return false;
@@ -228,6 +228,9 @@ static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo
 
        data_str = buf;
        switch(blob_id(attr)) {
+       case BLOBMSG_TYPE_UNSPEC:
+               sprintf(buf, "null");
+               break;
        case BLOBMSG_TYPE_BOOL:
                sprintf(buf, "%s", *(uint8_t *)data ? "true" : "false");
                break;