summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenn Knowles <kenn.knowles@gmail.com>2013-06-14 18:15:22 -0400
committerKenn Knowles <kenn.knowles@gmail.com>2013-06-14 18:15:22 -0400
commit9558f4ac442e5fe3fbcea5c38343008932aa7372 (patch)
tree797de158b8f59ee02271c8a2286d0eff3d85858e
parent27cdaad57dbe2941b671cadbf5195e22193ef1c7 (diff)
downloadjsonpath-rw-9558f4ac442e5fe3fbcea5c38343008932aa7372.tar.gz
Add quick example of `parent`
-rw-r--r--README.md4
1 files changed, 4 insertions, 0 deletions
diff --git a/README.md b/README.md
index 7113ed7..1c5c277 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,10 @@ $ python
>>> [match.value for match in parse('foo[*].id').find({'foo': [{'id': 'bizzle'}, {'baz': 3}]})]
['foo.bizzle', 'foo.[1]']
+# A handy extension: named operators like `parent`
+>>> [match.value for match in parse('a.*.b.`parent`.c').find({'a': {'x': {'b': 1, 'c': 'number one'}, 'y': {'b': 2, 'c': 'number two'}}})]
+['number two', 'number one']
+
# You can also build expressions directly quite easily
>>> jsonpath_expr_direct = Fields('foo').child(Slice('*')).child(Fields('baz')) # This is equivalent
```