Skip to content

jmespath

2,200 2 57 MIT
1.0.1 (17 Jun 2022) Feb 09 2022 260.0 million (month)

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

In web scraping, jmespath is a powerful tool for parsing and reshaping large JSON datasets. Jmespath is fast and easily extendible following it's own powerful query language.

For more see the Json parsing introduction section.

Example Use


import jmespath

data = {
    "data": {
        "info": {
            "products": [
                {"price": {"usd": 1}, "_type": "product", "id": "123"}, 
                {"price": {"usd": 2}, "_type": "product", "id": "345"}
            ]
        }
    }
}

# easily reshape nested dataset to flat structure:
jmespath.search("data.info.products[*].{id:id, price:price.usd}", data)
[{'id': '123', 'price': 1}, {'id': '345', 'price': 2}]

Alternatives / Similar


614 1.7.0 (19 days ago) Feb 09 2022 compare
209 0.2.25 (2 years ago) Feb 09 2022 compare
2,264 0.2.16 (6 months ago) May 19 2011 compare

Other Languages

380 1.8.9 (1 year, 6 days ago) Dec 03 2013 compare
169 19.0.5 (1 year, 2 months ago) Jun 10 2018 compare
258 v1.3.6 (2 months ago) Oct 15 2019 compare
mxj
624 per (1 year, 4 months ago) Feb 09 2017 compare
1,753 4.0.0 (3 years ago) Apr 18 2015 compare
Was this page helpful?