Python JSON Get
Get values from JSON objects usings a path expression. Optional type checking is possible:
>>> from jsonget import json_get, json_get_default, JList
>>> j = {
... "foo": {"num": 3.4, "s": "Text"},
... "arr": [10, 20, 30],
... }
>>> json_get(j, "/foo/num")
3.4
>>> json_get(j, "/arr[1]")
20
>>> json_get(j, "/foo/unknown")
Traceback (most recent call last):
...
ValueError: JSON path '/foo/unknown' not found
Values are optionally checked against one of the following types: str, int, float, bool, list, and dict. Checking for null values is not supported:
>>> json_get(j, "/foo/num", str)
Traceback (most recent call last):
...
TypeError: wrong JSON type str != float
float will match any number, int will only match numbers without a fractional part:
>>> json_get(j, "/foo/num", float)
3.4
>>> json_get(j, "/foo/num", int)
Traceback (most recent call last):
...
TypeError: wrong JSON type int != float
Additionally, the type of list values can be checked:
>>> json_get(j, "/arr", JList(int)) [10, 20, 30]
json_get_default() can be used to return a default value if a given path does not exist:
>>> json_get_default(j, "/bar", "default value") 'default value'
Metadata
Release files for json-get 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json_get-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for json_get-1.1.1-py3-none-any.whl |
Release files / json_get-1.1.1-py3-none-any.whl
| Download URL | json_get-1.1.1-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
884854fb225aa72e2a975dc545704f93e1f87f9377108c27fa27b0c0cca92374
|
|
BLAKE2b-256 checksum How to use checksums |
fef6a8fe09ed8b3db17ceb41ae21e54923256402c3fca90d8874fe9216721ae9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for json-get 1.1.1
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.