cli: supress printing "null" in non-export mode, output strings unescaped
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 6 Jan 2014 11:55:44 +0000 (11:55 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 6 Jan 2014 11:59:17 +0000 (11:59 +0000)
main.c

diff --git a/main.c b/main.c
index 7d232c5f656b21d80cdec72294192055823d176f..eaa1ee09216f2b22141804831205ba847dbcbea3 100644 (file)
--- 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;
+                       }
+               }
        }
 }