From: Jo-Philipp Wich Date: Mon, 6 Jan 2014 11:55:44 +0000 (+0000) Subject: cli: supress printing "null" in non-export mode, output strings unescaped X-Git-Url: https://git.librecmc.org/?p=oweals%2Fjsonpath.git;a=commitdiff_plain;h=f1e3aeb2526ea28db34c7bc714277c1dff26e5fc cli: supress printing "null" in non-export mode, output strings unescaped --- 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; + } + } } }