summaryrefslogtreecommitdiff
path: root/jsonpath.c
diff options
context:
space:
mode:
authorJoey Adams2010-07-06 04:51:48 +0000
committerJoey Adams2010-07-06 04:51:48 +0000
commitc93ed31284c3f9335d2744c4db2f54165ad264f4 (patch)
tree7c474e5e62daaba22d15f6281d45b427e71fdaee /jsonpath.c
parentb153d76442ba1ef1237c4cc36f491b3aff7b8510 (diff)
* Added json_get
* Affirmed (with a trivial test) that json_path returns its results breadth-first
Diffstat (limited to 'jsonpath.c')
-rw-r--r--jsonpath.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/jsonpath.c b/jsonpath.c
index 6c04bdb..a6ca56f 100644
--- a/jsonpath.c
+++ b/jsonpath.c
@@ -20,10 +20,10 @@
* This element is used so an otherwise empty JSONPath list won't be NULL.
* This allows us to use NULL to indicate an invalid JSONPath.
*
- * This function returns the second cell,
- * making sure the first is of type JP_ROOT.
+ * This function returns the first cell,
+ * making sure it is of type JP_ROOT.
*/
-static ListCell *jp_head(JSONPath *jp)
+static ListCell *jp_root(JSONPath *jp)
{
ListCell *cell;
jp_element *elem;
@@ -34,11 +34,19 @@ static ListCell *jp_head(JSONPath *jp)
elem = lfirst(cell);
Assert(elem->type == JP_ROOT);
- cell = lnext(cell);
return cell;
}
/*
+ * This function returns the second cell of a JSONPath list
+ * (the first cell after the JP_ROOT).
+ */
+static ListCell *jp_head(JSONPath *jp)
+{
+ return lnext(jp_root(jp));
+}
+
+/*
* Note that skip_spaces differs from skip_whitespace in json.c
* in that this function treats '\f' and '\v' as whitespace.
* This is because JSON does not accept these characters as