diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-03-17 03:50:03 +0400 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-03-17 03:50:03 +0400 |
commit | 00a833c5b6f44c8cf2a7a9838de32d0dc5400a90 (patch) | |
tree | 605bb40f1a9ed1e95eb54ffcb0bd9136f0ebc0f9 /jshn.c | |
parent | 49e6e062b8effe281a85de167c16c5f039b74442 (diff) |
jshn: add support for the double datatype
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'jshn.c')
-rw-r--r-- | jshn.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -112,6 +112,9 @@ static int add_json_element(const char *key, json_object *obj) case json_type_int: type = "int"; break; + case json_type_double: + type = "double"; + break; default: return -1; } @@ -141,6 +144,9 @@ static int add_json_element(const char *key, json_object *obj) case json_type_int: fprintf(stdout, "' %d;\n", json_object_get_int(obj)); break; + case json_type_double: + fprintf(stdout, "' %lf;\n", json_object_get_double(obj)); + break; default: return -1; } @@ -212,6 +218,8 @@ static void jshn_add_object_var(json_object *obj, bool array, const char *prefix new = json_object_new_string(var); } else if (!strcmp(type, "int")) { new = json_object_new_int(atoi(var)); + } else if (!strcmp(type, "double")) { + new = json_object_new_double(strtod(var, NULL)); } else if (!strcmp(type, "boolean")) { new = json_object_new_boolean(!!atoi(var)); } else { |