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.1.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for jsonparse-0.6.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68d918262ebf6f9653cb02d5c3e048294c755d011fe5ceb71c8174a755b173dd |
|
MD5 | db2e449c5bea0a1eb346450b08b30d0c |
|
BLAKE2b-256 | 3995e05afa97388a1480c997c3644487cf93c4c58aa08c18b62c0c4bb39b6c4d |