Switch to sqlite3's lemon parser generator.
[oweals/jsonpath.git] / main.c
diff --git a/main.c b/main.c
index 2bdb1106d400429a9794c831e09ca7710232b723..ebd52c0cecf0cbb5542cb52ce20a43ec9d6bd150 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
+ * Copyright (C) 2013-2014 Jo-Philipp Wich <jow@openwrt.org>
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -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;
+                       }
+               }
        }
 }
 
@@ -245,8 +263,9 @@ filter_json(int opt, struct json_object *jsobj, char *expr)
 
        if (!state || state->error)
        {
-               fprintf(stderr, "In expression '%s': %s\n",
-                       expr, state ? state->error : "Out of memory");
+               fprintf(stderr, "Syntax error near {%s}: %s\n",
+                       state ? expr + state->erroff : expr,
+                               state ? state->error : "Out of memory");
 
                goto out;
        }