Skip to main content

Another JSONPath implementation for Python.

Project description

Python JSONPath

A flexible JSONPath engine for Python.

License Tests
PyPi - Version Python versions


Table of Contents

Install

Install Python JSONPath using pip:

pip install python-jsonpath

Or Pipenv:

pipenv install -u python-jsonpath

Or from conda-forge:

conda install -c conda-forge python-jsonpath

Links

Examples

JSONPath

import jsonpath

data = {
    "users": [
        {
            "name": "Sue",
            "score": 100,
        },
        {
            "name": "John",
            "score": 86,
        },
        {
            "name": "Sally",
            "score": 84,
        },
        {
            "name": "Jane",
            "score": 55,
        },
    ]
}

user_names = jsonpath.findall("$.users[?@.score < 100].name", data)
print(user_names) # ['John', 'Sally', 'Jane']

JSON Pointer

Since version 0.8.0, we also include an RFC 6901 compliant implementation of JSON Pointer.

from jsonpath import pointer

data = {
    "users": [
        {
            "name": "Sue",
            "score": 100,
        },
        {
            "name": "John",
            "score": 86,
        },
        {
            "name": "Sally",
            "score": 84,
        },
        {
            "name": "Jane",
            "score": 55,
        },
    ]
}

sue_score = pointer.resolve("/users/0/score", data)
print(sue_score)  # 100

jane_score = pointer.resolve(["users", 3, "score"], data)
print(jane_score)  # 55

License

python-jsonpath is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_jsonpath-0.8.0.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_jsonpath-0.8.0-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file python_jsonpath-0.8.0.tar.gz.

File metadata

  • Download URL: python_jsonpath-0.8.0.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for python_jsonpath-0.8.0.tar.gz
Algorithm Hash digest
SHA256 4da057c5ab27430b9bf476c33fc809b441bcc6a1713965b79220cab6a9abea5c
MD5 7ec856e88c77701092a0c97686370ad6
BLAKE2b-256 d523cf94d8b9ef4519eb311ce1a92886bf4d570ab4e63c0fd60f21861207ad48

See more details on using hashes here.

File details

Details for the file python_jsonpath-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_jsonpath-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2672f9b280e099f650c982eaf9f22b1c186c6a8b5ac8a8344ae5d9d6bd6b7a3
MD5 195002f33db57fb7d9b612010668f907
BLAKE2b-256 1f5b844230d350b8ecd5fa44732cf91f0d900c20722efe9c29e1ea6482cb631a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page