Skip to main content

Python JsonPath

A Python tool that parses JSON documents using JsonPath

Inspired by: https://github.com/json-path/JsonPath

Quick Start

install it using the pip command

pip install pyjsonpath

Then:

>>> from pyjsonpath import JsonPath
>>> obj = {"name": "jsonpath"}
>>> JsonPath(obj, "$.name").load()
['jsonpath']
>>>

JsonPath Syntax

  • General Operators
operators description
$ The root element to query. This starts all path expressions.
@ The current node being processed by a filter predicate.
* Wildcard. Available anywhere a name or numeric are required.
.. Deep scan. Available anywhere a name is required.
. Dot-notated child
['<name>' (, '<name>')] Bracket-notated child or children
[<number> (, <number>)] Array index or indexes
[start:end] Array slice operator
[?(<expression>)] Filter expression. Expression must evaluate to a boolean value.
  • Filter Operators
operators description
== left is equal to right (note that 1 is not equal to '1')
!= left is not equal to right
< left is less than right
<= left is less or equal to right
> left is greater than right
>= left is greater than or equal to right
=~ left matches regular expression [?(@.name =~ /foo.*?/i)]
in left exists in right [?(@.size in ['S', 'M'])]
nin left does not exists in right
subsetof left is a subset of right [?(@.sizes subsetof ['S', 'M', 'L'])]
anyof left has an intersection with right [?(@.sizes anyof ['M', 'L'])]
noneof left has no intersection with right [?(@.sizes noneof ['M', 'L'])]
size size of left (array or string) should match right
empty left (array or string) should be empty
  • Functions
operators description
min() Provides the min value of an array of numbers
max() Provides the max value of an array of numbers
avg() Provides the average value of an array of numbers
stddev() Provides the standard deviation value of an array of numbers
length() Provides the length of an array
sum() Provides the sum value of an array of numbers
keys() Provides the property keys (An alternative for terminal tilde ~)

Metadata

Release files for pyjsonpath 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyjsonpath 1.2.3
File Size Uploaded Provenance Actions
pyjsonpath-1.2.3.tar.gz 6.3 kB Without provenance Details for pyjsonpath-1.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyjsonpath 1.2.3
File Interpreter ABI Platform Actions
pyjsonpath-1.2.3-py3-none-any.whl Python 3 none any Details for pyjsonpath-1.2.3-py3-none-any.whl

Total release size: 12.1 kB

Release files / pyjsonpath-1.2.3.tar.gz

Download URL pyjsonpath-1.2.3.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f12e7062023de09f2a82bd04eb8c1ce3a5e4fb41e79783b3512b6cdea7434f7c
BLAKE2b-256 checksum
How to use checksums
fa84d9dee282d774452071334d6d0799255c9c9d33aff67337d4a85d85904806
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5

Release files / pyjsonpath-1.2.3-py3-none-any.whl

Download URL pyjsonpath-1.2.3-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39359a9ef8bec5a72b17623f52a18bdbd8cf19d6adf071fe29e829f88ebd765d
BLAKE2b-256 checksum
How to use checksums
6ed6b7a6777dcc0ab7b79edcbfa286861ee94537679ac64e3d79221b6038dd10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5

Security for pyjsonpath 1.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page