A Python toolkit for parsing JSON document
Project description
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 ~) |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyjsonpath-1.2.3.tar.gz
(6.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyjsonpath-1.2.3.tar.gz.
File metadata
- Download URL: pyjsonpath-1.2.3.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f12e7062023de09f2a82bd04eb8c1ce3a5e4fb41e79783b3512b6cdea7434f7c
|
|
| MD5 |
cc15c9e829de2d4b3be8cb5593dff107
|
|
| BLAKE2b-256 |
fa84d9dee282d774452071334d6d0799255c9c9d33aff67337d4a85d85904806
|
File details
Details for the file pyjsonpath-1.2.3-py3-none-any.whl.
File metadata
- Download URL: pyjsonpath-1.2.3-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39359a9ef8bec5a72b17623f52a18bdbd8cf19d6adf071fe29e829f88ebd765d
|
|
| MD5 |
19a73efcf08683bdd0f0d7ce8a5aafa3
|
|
| BLAKE2b-256 |
6ed6b7a6777dcc0ab7b79edcbfa286861ee94537679ac64e3d79221b6038dd10
|