Skip to content

Commit 9558f4a

Browse files
committed
Add quick example of parent
1 parent 27cdaad commit 9558f4a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ $ python
4848
>>> [match.value for match in parse('foo[*].id').find({'foo': [{'id': 'bizzle'}, {'baz': 3}]})]
4949
['foo.bizzle', 'foo.[1]']
5050

51+
# A handy extension: named operators like `parent`
52+
>>> [match.value for match in parse('a.*.b.`parent`.c').find({'a': {'x': {'b': 1, 'c': 'number one'}, 'y': {'b': 2, 'c': 'number two'}}})]
53+
['number two', 'number one']
54+
5155
# You can also build expressions directly quite easily
5256
>>> jsonpath_expr_direct = Fields('foo').child(Slice('*')).child(Fields('baz')) # This is equivalent
5357
```

0 commit comments

Comments
 (0)