jsonkeysearch: Searches for keys in JSON format files.
Project description
jsonkeysearch
Description
jsonkeysearch is a Python library that recursively searches for keys in JSON format files.
Installaction
Usage
from jsonkeysearch import JSONKeySearch
# https://json.org/example.html
json_example = {
"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"},
]
},
}
}
target = JSONKeySearch(json_example)
# [1] Append all dictionary with onclick as key in a list
key_ = "onclick"
value_ = "" # All value in key
target.search(key=key_, value=value_)
print(target.jsonObject)
# [
# {"value": "New", "onclick": "CreateNewDoc()"},
# {"value": "Open", "onclick": "OpenDoc()"},
# {"value": "Close", "onclick": "CloseDoc()"},
# ]
# [2] Append dictionary in a list with onclick as key and 'Open' as value
key_="onclick"
value_ = "Open"
target.search(key = key_, value = value_)
print(target.jsonObject)
# [{"value": "Open", "onclick": "OpenDoc()"}]
for dict_ in target.jsonObject:
print(dict_[key_])
# 'OpenDoc()'
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
jsonkeysearch-0.1.1.tar.gz
(4.5 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 jsonkeysearch-0.1.1.tar.gz.
File metadata
- Download URL: jsonkeysearch-0.1.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6533dc9a6a2654247f0448f5b01d152d43736d0e0ef5257a8f3305d03e9790e
|
|
| MD5 |
6773e6ae759df17ecb2c11f9f3b27474
|
|
| BLAKE2b-256 |
06033cd72e1808d1680b94856162ac62aa95246407ed12f64bb7435f6457c7b5
|
File details
Details for the file jsonkeysearch-0.1.1-py3-none-any.whl.
File metadata
- Download URL: jsonkeysearch-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1337c50a35e8fd75fd6730a63e068192256e54ad9caefcee25b1bc1a47e6c9a
|
|
| MD5 |
d20287aefed7490dc15e4c5913d7386f
|
|
| BLAKE2b-256 |
96665cfa19f2744e88745a1b55b808213a7dcc4b07d32637193aebe6295894ef
|