Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Gaul <andre@gaul.io>2016-11-19 20:55:49 +0300
committerFelix Fietkau <nbd@nbd.name>2017-01-04 23:36:31 +0300
commit7f671b1e68a6664b5baf3e3cffc1bb0880984267 (patch)
treeb8c212bc9c1fcf230975f5a0e2d86bfec6420c5c /blobmsg_json.c
parent0fe13749d095ca22c788e55902979323e85367c3 (diff)
blobmsg: add support for double
This adds support for double floating point type to make it more JSON compatible. For type checking it also adds a stub BLOB_ATTR_DOUBLE type. If necessary, the accessor functions for blob can be added later Signed-off-by: André Gaul <andre@gaul.io> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'blobmsg_json.c')
-rw-r--r--blobmsg_json.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/blobmsg_json.c b/blobmsg_json.c
index 8a6ed8f..ca9dd1a 100644
--- a/blobmsg_json.c
+++ b/blobmsg_json.c
@@ -69,6 +69,9 @@ bool blobmsg_add_json_element(struct blob_buf *b, const char *name, json_object
case json_type_int:
blobmsg_add_u32(b, name, json_object_get_int(obj));
break;
+ case json_type_double:
+ blobmsg_add_double(b, name, json_object_get_double(obj));
+ break;
case json_type_null:
blobmsg_add_field(b, BLOBMSG_TYPE_UNSPEC, name, NULL, 0);
break;
@@ -255,6 +258,9 @@ static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo
case BLOBMSG_TYPE_INT64:
sprintf(buf, "%" PRId64, (int64_t) be64_to_cpu(*(uint64_t *)data));
break;
+ case BLOBMSG_TYPE_DOUBLE:
+ sprintf(buf, "%lf", blobmsg_get_double(attr));
+ break;
case BLOBMSG_TYPE_STRING:
blobmsg_format_string(s, data);
return;