Instead of abort parsing, properly deal with "null" values by implementing
support for reading and formatting such values.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
{
char *type;
- if (!obj)
- return -1;
-
switch (json_object_get_type(obj)) {
case json_type_object:
type = "object";
case json_type_double:
type = "double";
break;
+ case json_type_null:
+ type = "null";
+ break;
default:
return -1;
}
case json_type_double:
fprintf(stdout, "' %lf;\n", json_object_get_double(obj));
break;
+ case json_type_null:
+ fprintf(stdout, "';\n");
+ break;
default:
return -1;
}
new = json_object_new_double(strtod(var, NULL));
} else if (!strcmp(type, "boolean")) {
new = json_object_new_boolean(!!atoi(var));
+ } else if (!strcmp(type, "null")) {
+ new = NULL;
} else {
return;
}
_json_add_generic double "$1" "$2" "$cur"
}
+json_add_null() {
+ local cur
+ _json_get_var cur JSON_CUR
+ _json_add_generic null "$1" "" "$cur"
+}
+
# functions read access to json variables
json_load() {