Metadata-Version: 2.0
Name: jmespath
Version: 0.9.0
Summary: JSON Matching Expressions
Author: James Saryerwinnie
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4


.. image:: Chat.svg

.. image::

JMESPath (pronounced "james path") allows you to declaratively specify how to
extract elements from a JSON document.

For example, given this document::

    {"foo": {"bar": "baz"}}

The jmespath expression ```` will return "baz".

JMESPath also supports:

Referencing elements in a list.  Given the data::

    {"foo": {"bar": ["one", "two"]}}

The expression: ``[0]`` will return "one".
You can also reference all the items in a list using the ``*``

   {"foo": {"bar": [{"name": "one"}, {"name": "two"}]}}

The expression: ``[*].name`` will return ["one", "two"].
Negative indexing is also supported (-1 refers to the last element
in the list).  Given the data above, the expression
``[-1].name`` will return "two".

The ``*`` can also be used for hash types::

   {"foo": {"bar": {"name": "one"}, "baz": {"name": "two"}}}

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


The ```` library has two functions
that operate on python data structures.  You can use ``search``
and give it the jmespath expression and the data::

    >>> import jmespath
    >>> path ='', {'foo': {'bar': 'baz'}})

Similar to the ``re`` module, you can use the ``compile`` function
to compile the JMESPath expression and use this parsed expression
to perform repeated searches::

    >>> import jmespath
    >>> expression = jmespath.compile('')
    >>>{'foo': {'bar': 'baz'}})
    >>>{'foo': {'bar': 'other'}})

This is useful if you're going to use the same jmespath expression to
search multiple documents.  This avoids having to reparse the
JMESPath expression each time you search a new document.


You can provide an instance of ``jmespath.Options`` to control how
a JMESPath expression is evaluated.  The most common scenario for
using an ``Options`` instance is if you want to have ordered output
of your dict keys.  To do this you can use either of these options::

    >>> import jmespath
    >>>'{a: a, b: b},
    ...                 mydata,
    ...                 jmespath.Options(dict_cls=collections.OrderedDict))

    >>> import jmespath
    >>> parsed = jmespath.compile('{a: a, b: b}')
    >>>'{a: a, b: b},
    ...               mydata,
    ...               jmespath.Options(dict_cls=collections.OrderedDict))


If you'd like to learn more about the JMESPath language, you can check out
the `JMESPath tutorial <>`__.  Also check
out the `JMESPath examples page <>`__ for
examples of more complex jmespath queries.

The grammar is specified using ABNF, as described in
`RFC4234 <>`_.
You can find the most up to date
`grammar for JMESPath here <>`__.

You can read the full
`JMESPath specification here <>`__.


In addition to the unit tests for the jmespath modules,
there is a ``tests/compliance`` directory that contains
.json files with test cases.  This allows other implementations
to verify they are producing the correct output.  Each json
file is grouped by feature.


Join us on our `Gitter channel <>`__
if you want to chat or if you have any questions.