diff options
author | bi <bisnard@antidot.net> | 2013-05-15 16:19:55 +0200 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2013-12-02 11:18:47 +0000 |
commit | e4a054484774fd0849ca18617b6e20d15964fdd8 (patch) | |
tree | 60a68b28313c6c86d27b95abc948caa0944ec0f8 /json-glib/json-path.c | |
parent | b5570400cbd95f46373dfce2877c6599802bec21 (diff) | |
download | json-glib-e4a054484774fd0849ca18617b6e20d15964fdd8.tar.gz |
path: compile and query path '$' to retrieve root node
Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
Diffstat (limited to 'json-glib/json-path.c')
-rw-r--r-- | 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: |