From e4a054484774fd0849ca18617b6e20d15964fdd8 Mon Sep 17 00:00:00 2001 From: bi Date: Wed, 15 May 2013 16:19:55 +0200 Subject: path: compile and query path '$' to retrieve root node Signed-off-by: Emmanuele Bassi --- json-glib/json-path.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'json-glib/json-path.c') 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: -- cgit v1.2.1