X-Git-Url: http://git.archive.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=blobmsg_json.c;fp=blobmsg_json.c;h=7a4ab7b15661bfcd2a8e63b30112e70ca8332652;hp=f16635834fb9ccc53ba76515dd08e4f04ab4e2f2;hb=54a0b49326904fc3281c72cd9d9f1fe950e39d05;hpb=c4b79e4b5448abcd04c1848e212a237e8b17c3de diff --git a/blobmsg_json.c b/blobmsg_json.c index f166358..7a4ab7b 100644 --- a/blobmsg_json.c +++ b/blobmsg_json.c @@ -71,12 +71,10 @@ bool blobmsg_add_json_element(struct blob_buf *b, const char *name, json_object return ret; } -bool blobmsg_add_json_from_string(struct blob_buf *b, const char *str) +static bool __blobmsg_add_json(struct blob_buf *b, json_object *obj) { - json_object *obj; bool ret = false; - obj = json_tokener_parse(str); if (is_error(obj)) return false; @@ -90,6 +88,16 @@ out: return ret; } +bool blobmsg_add_json_from_file(struct blob_buf *b, const char *file) +{ + return __blobmsg_add_json(b, json_object_from_file(file)); +} + +bool blobmsg_add_json_from_string(struct blob_buf *b, const char *str) +{ + return __blobmsg_add_json(b, json_tokener_parse(str)); +} + struct strbuf { int len;