JSONPath (RFC 9535)

1.0.0 · active · verified Thu Apr 16

jsonpath-rfc9535 is a Python library that provides a comprehensive and compliant implementation of JSONPath, as defined by RFC 9535. It allows users to query and manipulate JSON data structures using standard JSONPath expressions. The library is currently at version 1.0.0 and maintains an active development cadence with regular updates.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import JSONPath, define a JSONPath expression, and use it to find matching nodes in a JSON document.

from jsonpath import JSONPath

data = {
    "store": {
        "book": [
            { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 },
            { "category": "fiction", "author": "J.R.R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 }
        ],
        "bicycle": { "color": "red", "price": 19.95 }
    }
}

# Find all book titles
path = JSONPath("$.store.book[*].title")
for node in path.findall(data):
    print(node.value)

# Find books cheaper than 10
path_cheap_books = JSONPath("$.store.book[?(@.price < 10)]")
for node in path_cheap_books.findall(data):
    print(node.value)

view raw JSON →