@@ -10,7 +10,7 @@ JMESPath
10
10
:target: http://travis-ci.org/jmespath/jmespath.py
11
11
12
12
13
- JMESPath (pronounced `` \ˈjāmz path\ `` ) allows you to declaratively specify how to
13
+ JMESPath (pronounced "james path" ) allows you to declaratively specify how to
14
14
extract elements from a JSON document.
15
15
16
16
For example, given this document::
@@ -42,13 +42,42 @@ The ``*`` can also be used for hash types::
42
42
43
43
The expression: ``foo.*.name `` will return ["one", "two"].
44
44
45
- Join us on our `Gitter channel <https://gitter.im/jmespath/chat >`__
46
- if you want to chat or if you have any questions.
45
+
46
+ API
47
+ ===
48
+
49
+ The ``jmespath.py `` library has two functions
50
+ that operate on python data structures. You can use ``search ``
51
+ and give it the jmespath expression and the data::
52
+
53
+ >>> import jmespath
54
+ >>> path = jmespath.search('foo.bar', {'foo': {'bar': 'baz'}})
55
+ 'baz'
56
+
57
+ Similar to the ``re `` module, you can use the ``compile `` function
58
+ to compile the JMESPath expression and use this parsed expression
59
+ to perform repeated searches::
60
+
61
+ >>> import jmespath
62
+ >>> expression = jmespath.compile('foo.bar')
63
+ >>> expression.search({'foo': {'bar': 'baz'}})
64
+ 'baz'
65
+ >>> expression.search({'foo': {'bar': 'other'}})
66
+ 'other'
67
+
68
+ This is useful if you're going to use the same jmespath expression to
69
+ search multiple documents. This avoids having to reparse the
70
+ JMESPath expression each time you search a new document.
47
71
48
72
49
73
Specification
50
74
=============
51
75
76
+ If you'd like to learn more about the JMESPath language, you can check out
77
+ the `JMESPath tutorial <http://jmespath.org/tutorial.html >`__. Also check
78
+ out the `JMESPath examples page <http://jmespath.org/examples.html >`__ for
79
+ examples of more complex jmespath queries.
80
+
52
81
The grammar is specified using ABNF, as described in
53
82
`RFC4234 <http://www.ietf.org/rfc/rfc4234.txt >`_.
54
83
You can find the most up to date
@@ -57,9 +86,6 @@ You can find the most up to date
57
86
You can read the full
58
87
`JMESPath specification here <http://jmespath.org/specification.html >`__.
59
88
60
- If you'd like to learn more about the JMESPath language, you can check out
61
- the `JMESPath tutorial <http://jmespath.org/tutorial.html >`__.
62
-
63
89
64
90
Testing
65
91
=======
@@ -70,26 +96,9 @@ there is a ``tests/compliance`` directory that contains
70
96
to verify they are producing the correct output. Each json
71
97
file is grouped by feature.
72
98
73
- Python Library
74
- ==============
75
99
76
- The included python implementation has two convenience functions
77
- that operate on python data structures. You can use ``search ``
78
- and give it the jmespath expression and the data::
79
-
80
- >>> import jmespath
81
- >>> path = jmespath.search('foo.bar', {'foo': {'bar': 'baz'}})
82
- 'baz'
83
-
84
- Similar to the ``re `` module, you can store the compiled expressions
85
- and reuse them to perform repeated searches::
86
-
87
- >>> import jmespath
88
- >>> path = jmespath.compile('foo.bar')
89
- >>> path.search({'foo': {'bar': 'baz'}})
90
- 'baz'
91
- >>> path.search({'foo': {'bar': 'other'}})
92
- 'other'
100
+ Discuss
101
+ =======
93
102
94
- You can also use the `` jmespath.parser.Parser `` class directly
95
- if you want more control .
103
+ Join us on our ` Gitter channel < https://gitter.im/jmespath/chat >`__
104
+ if you want to chat or if you have any questions .
0 commit comments