JsonSearch
JsonSearch is a simple, yet effcient python library for searhing specific elements in json data.
>>> from jsonsearch import JsonSearch
>>> test_data = {
... "store": {
... "book": [
... {
... "category": "reference",
... "author": "Nigel Rees",
... "title": "Sayings of the Century",
... "price": 8.95
... },
... {
... "category": "fiction",
... "author": "Evelyn Waugh",
... "title": "Sword of Honour",
... "price": 12.99
... },
... {
... "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
... }
... },
... "expensive": 10
... }
>>> jsondata = JsonSearch(object=test_data, mode='j')
>>> jsondata.search_all_value(key='title')
['Sayings of the Century', 'Sword of Honour', 'Moby Dick', 'The Lord of the Rings']
>>> jsondata.search_all_path(key='title')
[['store', 'book', 0, 'title'], ['store', 'book', 1, 'title'], ['store', 'book', 2, 'title'], ['store', 'book', 3, 'title']]
>>> jsondata.search_first_value(key='title')
'Sayings of the Century'
>>> jsondata.search_first_path(key='title')
['store', 'book', 0, 'title']
When json data have nested objects, JsonSearch allows you to find specific elements in json data easily.
Take the program above as an example, if you want to get the first 'title' value in data, you don't need to use test_data['store']['book'][0]['title'] anymore, you can just use jsondata.search_first_value(key='title').
Install
JsonSearch is available on PyPI:
pip install jsonsearch
or
pip install --index-url https://pypi.org/simple/ jsonsearch
Metadata
Release files for jsonsearch 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jsonsearch-0.0.2.tar.gz | 15.6 kB | Without provenance | Details for jsonsearch-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsonsearch-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for jsonsearch-0.0.2-py3-none-any.whl |
Total release size: 31.1 kB
Release files / jsonsearch-0.0.2.tar.gz
| Download URL | jsonsearch-0.0.2.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f215e8fc7d5783e4d193f6e262b20976bd528572c10f498b81293eac2cb73fe2
|
|
BLAKE2b-256 checksum How to use checksums |
92e3a57c360748a0ebc3a11ba256e5152280943db77d12b257d68b0f0b99b083
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.12
|
Release files / jsonsearch-0.0.2-py3-none-any.whl
| Download URL | jsonsearch-0.0.2-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c04369acfd7d51bfd65e0647f56c81fbfce2ab501ff98bc4e98b696be0e711a
|
|
BLAKE2b-256 checksum How to use checksums |
1f91b5a47df8c9ba5fa4be7c850435231d347cba3fc1a6320ca6c079aa511759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.12
|
Security for jsonsearch 0.0.2
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.