python-jsonslicer
Port variant v11
Summary Stream JSON parser with iterator interface (3.11)
BROKEN
Package version 0.1.8
Homepage https://github.com/AMDmi3/jsonslicer
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v12
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 09 AUG 2024, 21:24:17 UTC
Port created 05 MAR 2024, 06:30:48 UTC
Subpackage Descriptions
single # jsonslicer - stream JSON parser [image] [CI] [codecov] [PyPI downloads] [PyPI version] [PyPI pythons] [Github commits (since latest release)] ## Overview JsonSlicer performs a **stream** or **iterative**, **pull** JSON parsing, which means it **does not load** whole JSON into memory and is able to parse **very large** JSON files or streams. The module is written in C and uses [YAJL] JSON parsing library, so it's also quite **fast**. JsonSlicer takes a **path** of JSON map keys or array indexes, and provides **iterator interface** which yields JSON data matching given path as complete Python objects. ## Example ```json { "friends": [ {"name": "John", "age": 31}, {"name": "Ivan", "age": 26} ], "colleagues": { "manager": {"name": "Jack", "age": 33}, "subordinate": {"name": "Lucy", "age": 21} } } ` `python from jsonslicer import JsonSlicer # Extract specific elements: with open('people.json') as data: ivans_age = next(JsonSlicer(data, ('friends', 1, 'age'))) # 26 with open('people.json') as data: managers_name = next(JsonSlicer(data, ('colleagues', 'manager', 'name'))) # 'Jack' # Iterate over collection(s) by using wildcards in the path: with open('people.json') as data: for person in JsonSlicer(data, ('friends', None)): print(person) # {'name': 'John', 'age': 31} # {'name': 'Ivan', 'age': 26} # Iteration over both arrays and dicts is possible, even at the same time with open('people.json') as data: for person in JsonSlicer(data, (None, None)): print(person) # {'name': 'John', 'age': 31} # {'name': 'Ivan', 'age': 26} # {'name': 'Jack', 'age': 33} # {'name': 'Lucy', 'age': 21} # Map key of returned objects is available on demand... with open('people.json') as data: for position, person in JsonSlicer(data, ('colleagues', None), path_mode='map_keys'): print(position, person) # 'manager' {'name': 'Jack', 'age': 33} # 'subordinate' {'name': 'Lucy', 'age': 21} # ...as well as complete path information with open('people.json') as data: for *path, person in JsonSlicer(data, (None, None), path_mode='full'): print(path, person) # ('friends', 0) {'name': 'John', 'age': 31}) # ('friends', 1) {'name': 'Ivan', 'age': 26}) # ('colleagues', 'manager') {'name': 'Jack', 'age': 33}) # ('colleagues', 'subordinate') {'name': 'Lucy', 'age': 21}) # Extract all instances of deep nested field with open('people.json') as data: age_sum = sum(JsonSlicer(data, (None, None, 'age'))) # 111 ``` ## API ``` jsonslicer.JsonSlicer( file, path_prefix, read_size=1024, path_mode=None, yajl_allow_comments=False, yajl_dont_validate_strings=False,
Configuration Switches (platform-specific settings discarded)
PY311 ON Build using Python 3.11 PY312 OFF Build using Python 3.12
Package Dependencies by Type
Build (only) yajl:dev:std
pkgconf:primary:std
python-setuptools:single:v11
autoselect-python:single:std
Build and Runtime yajl:primary:std
python311:single:std
Runtime (only) ravensys-gcc:cxx_run:std (single subpackage)
ravensys-gcc:libs:std (single subpackage)
Download groups
main mirror://PYPI/j/jsonslicer
Distribution File Information
12d953b5096cc997a8c6dc81417c510ab061090e0f5f960655331a43e520eaa2 23902 jsonslicer-0.1.8.tar.gz
Ports that require python-jsonslicer:v11
No other ports depend on this one.