From f1e3aeb2526ea28db34c7bc714277c1dff26e5fc Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 6 Jan 2014 11:55:44 +0000 Subject: [PATCH] cli: supress printing "null" in non-export mode, output strings unescaped --- main.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 7d232c5..eaa1ee0 100644 --- a/main.c +++ b/main.c @@ -179,7 +179,25 @@ export_value(struct list_head *matches, const char *prefix) else { list_for_each_entry(item, matches, list) - printf("%s\n", json_object_to_json_string(item->jsobj)); + { + switch (json_object_get_type(item->jsobj)) + { + case json_type_object: + case json_type_array: + case json_type_boolean: + case json_type_int: + case json_type_double: + printf("%s\n", json_object_to_json_string(item->jsobj)); + break; + + case json_type_string: + printf("%s\n", json_object_get_string(item->jsobj)); + break; + + case json_type_null: + break; + } + } } } -- 2.25.1