[json-glib] path: compile and query path '$' to retrieve root node



commit e4a054484774fd0849ca18617b6e20d15964fdd8
Author: bi <bisnard antidot net>
Date:   Wed May 15 16:19:55 2013 +0200

    path: compile and query path '$' to retrieve root node
    
    Signed-off-by: Emmanuele Bassi <ebassi gnome org>

 json-glib/json-path.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/json-glib/json-path.c b/json-glib/json-path.c
index 6199f51..e59a285 100644
--- a/json-glib/json-path.c
+++ b/json-glib/json-path.c
@@ -439,7 +439,7 @@ json_path_compile (JsonPath    *path,
                 return FALSE;
               }
 
-            if (!(*(p + 1) == '.' || *(p + 1) == '['))
+            if (!(*(p + 1) == '.' || *(p + 1) == '[' || *(p + 1) == '\0'))
               {
                 /* translators: the %c is the invalid character */
                 g_set_error (error, JSON_PATH_ERROR,
@@ -741,7 +741,10 @@ walk_path_node (GList      *path,
   switch (node->node_type)
     {
     case JSON_PATH_NODE_ROOT:
-      walk_path_node (path->next, root, results);
+      if (path->next != NULL)
+          walk_path_node (path->next, root, results);
+      else
+          json_array_add_element (results, json_node_copy (root));
       break;
 
     case JSON_PATH_NODE_CHILD_MEMBER:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]