Switch to sqlite3's lemon parser generator.
[oweals/jsonpath.git] / main.c
diff --git a/main.c b/main.c
index 7d232c5f656b21d80cdec72294192055823d176f..ebd52c0cecf0cbb5542cb52ce20a43ec9d6bd150 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;
+                       }
+               }
        }
 }
 
@@ -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;
        }