Skip to content

Commit 76c7345

Browse files
committed
Cleanup README, reorganize some sections
1 parent 462c0de commit 76c7345

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

README.rst

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ JMESPath
1010
:target: http://travis-ci.org/jmespath/jmespath.py
1111

1212

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
1414
extract elements from a JSON document.
1515

1616
For example, given this document::
@@ -42,13 +42,42 @@ The ``*`` can also be used for hash types::
4242

4343
The expression: ``foo.*.name`` will return ["one", "two"].
4444

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.
4771

4872

4973
Specification
5074
=============
5175

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+
5281
The grammar is specified using ABNF, as described in
5382
`RFC4234 <http://www.ietf.org/rfc/rfc4234.txt>`_.
5483
You can find the most up to date
@@ -57,9 +86,6 @@ You can find the most up to date
5786
You can read the full
5887
`JMESPath specification here <http://jmespath.org/specification.html>`__.
5988

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-
6389

6490
Testing
6591
=======
@@ -70,26 +96,9 @@ there is a ``tests/compliance`` directory that contains
7096
to verify they are producing the correct output. Each json
7197
file is grouped by feature.
7298

73-
Python Library
74-
==============
7599

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+
=======
93102

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

Comments
 (0)