summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2014-01-06 11:55:44 +0000
committerJo-Philipp Wich <jow@openwrt.org>2014-01-06 11:59:17 +0000
commitf1e3aeb2526ea28db34c7bc714277c1dff26e5fc (patch)
treeba2abc29aceae4c8a08a16ce31bacfe4a80868b6
parent325454c60f282994cf79c69d49edbcea53f2e924 (diff)
downloadjsonpath-f1e3aeb2526ea28db34c7bc714277c1dff26e5fc.tar.gz
cli: supress printing "null" in non-export mode, output strings unescaped
-rw-r--r--main.c20
1 files changed, 19 insertions, 1 deletions
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;
+ }
+ }
}
}