complete tool for the JSON
Project description
JSONWAY
Jsonway is the one stop to manage the JSON using the python . All the operations can be done using the JSONway .
Installation
pip install jsonway
Usage
Sample JSON
{
"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
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
Lets say , we have to find the nested key author in the above JSON
import json
from jsonway.mainjsonway import *
with open('sample.json') as json_file:
data = json.load(json_file)
print(list(findkey('author', data, [])))
# output :[['store', 'book', 0, 'author'], ['store', 'book', 1, 'author'], ['store', 'book', 2, 'author'], ['store', 'book', 3, 'author']]
if you want to find the key and value then
print(list(findkeyvalue("title", data, [], "Sayings of the Century")))
if you want to find value then
print(list(findvalue("Sayings of the Century", data, [])))
if you want to get the value from a path then the path must be in the list form
getFromDict(data, ['store', 'book', 0, 'author'])
if you want to set the value at a particular key then
setInDict(dataDict, mapList, value)
to find all the keys values then
print(list(findallvalues('title', data)))
output : ['Sayings of the Century', 'Sword of Honour', 'Moby Dick', 'The Lord of the Rings']
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 jsonway-1.0.2.tar.gz.
File metadata
- Download URL: jsonway-1.0.2.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9ae0472c4c7a872e9627e3c39a95e8b1e736aa501ca91b7f587d1e83172a646
|
|
| MD5 |
2c56ba0fb8dc1a34ef1b9181db297f9a
|
|
| BLAKE2b-256 |
bd30ad2f98e659dcbc46eb1335b92bc1eeb3a77becd1c548ed31ea460924141d
|
File details
Details for the file jsonway-1.0.2-py3-none-any.whl.
File metadata
- Download URL: jsonway-1.0.2-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a14921aa4e1aff7e1e20fe7d65971915597f9e31e8ed49ed2d7999d766cf6b1
|
|
| MD5 |
545cce84d72ff68df42c24011b479bfe
|
|
| BLAKE2b-256 |
30f9a5e8c6126892e82570419d46daea99690eeadc30ed05cf770c75fa3d44dc
|