[json-glib/json-glib-0-14] path: Fix get all array elements with wildcard
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [json-glib/json-glib-0-14] path: Fix get all array elements with wildcard
- Date: Fri, 11 Jan 2013 17:53:01 +0000 (UTC)
commit 8972f794373e35cff7cb00a544d530109e122386
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Fri Jan 11 15:03:08 2013 +0000
path: Fix get all array elements with wildcard
Using the same data as in tests, asking for $['store']['book'][*] JSON path
should return all the book objects in an array.
But that array is returned inside another array, dupped several times.
https://bugzilla.gnome.org/show_bug.cgi?id=691557
(cherry picked from commit e348b1fa88823ddb18fb8d2a2d1acea94c9f9448)
Signed-off-by: Emmanuele Bassi <ebassi gnome org>
json-glib/json-path.c | 2 +-
json-glib/tests/path.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/json-glib/json-path.c b/json-glib/json-path.c
index abcc505..6fa9d82 100644
--- a/json-glib/json-path.c
+++ b/json-glib/json-path.c
@@ -896,7 +896,7 @@ walk_path_node (GList *path,
else
{
JSON_NOTE (PATH, "glob match element '%d'", i);
- json_array_add_element (results, json_node_copy (root));
+ json_array_add_element (results, json_node_copy (element));
}
}
g_list_free (elements);
diff --git a/json-glib/tests/path.c b/json-glib/tests/path.c
index 67d2a87..902f60e 100644
--- a/json-glib/tests/path.c
+++ b/json-glib/tests/path.c
@@ -79,6 +79,10 @@ static const struct {
"$..book[:2]",
"[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":\"8.95\"},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":\"12.99\"}]"
},
+ {
+ "$['store']['book'][*]",
+ "[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":\"8.95\"},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":\"12.99\"},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":\"8.99\"},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":\"22.99\"}]"
+ },
};
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]