Search through JSON data key:values by key(s)
Project description
jsonparse
jsonparse is a simple JSON parsing library. Extract the values from key:value pairs providing the key(s).
Install
pip install jsonparse
Usage
from jsonparse import Parser
parse = Parser(stack_trace=False, queue_trace=False)
data = [
{"key": 1},
{"key": 2},
{"my":
{"key":
{"chain":"A"}
}
},
{"your":
{"key":
{"chain":"B"}
}
}
]
parse.key(data, 'key')
[{'chain': 'B'}, {'chain': 'A'}, 2, 1]
parse.key(data, 'chain')
['B', 'A']
parse.key_chain(data, ['my', 'key', 'chain'])
['A']
parse.key_chain(data, ['key'])
[1, 2]
parse.key_chain(data, ['*', 'key', 'chain'])
['A', 'B']
parse.key_chain(data, ['*', 'key', '*'])
['A', 'B']
API
key(data: dict | list, key: str): -> list
- Provide JSON data as a dictionary or a list, as well as the key as a string
- Returns a list of values that match the corresponding key.
key_chain(data: dict | list, keys: list): -> list
- Provide JSON data as a dictionary or a list, as well as a list of keys as strings.
- Returns a list of values that match the corresponding key chain.
Wildcard '*' can be used as key(s) to match any.
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
jsonparse-0.6.2.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for jsonparse-0.6.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6106e727486e7d144e840d727a5e1b1be6ff90ccd7210e2db4e4c94d3447374b |
|
MD5 | 31be2d47c980c9b11482844e77e77980 |
|
BLAKE2b-256 | 28675d38ac016ece6fbf499534e93bad606b9803e6f136d6523b94a55b29482d |