skip to navigation
skip to content

Not Logged In

jmespath 0.3.0

JSON Matching Expressions

Latest Version: 0.4.0


JMESPath (pronounced "jaymz 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"].

**NOTE: jmespath is being actively developed.  There are a number
of features it does not currently support that may be added in the


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


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.

Python Library

The included python implementation has two convenience 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 store the compiled expressions
and reuse them to perform repeated searches::

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

You can also use the ``jmespath.parser.Parser`` class directly
if you want more control.

.. _RFC4234:
File Type Py Version Uploaded on Size
jmespath-0.3.0.tar.gz (md5) Source 2014-02-28 16KB
  • Downloads (All Versions):
  • 14413 downloads in the last day
  • 96337 downloads in the last week
  • 345638 downloads in the last month