Easier traversing and exploration of JSON structures
Project description
ez-json-traverse
For easier traversing and exploration of JSON structures.
Provides a traversable sequence EZJL
, traversable mapping EZJD
and convenience methods like as_traversable
.
Starting off
$ pip install ez-json-traverse
followed by
from ezjt import as_traversable
Dict stuff
d = {
'a': {'name': 'Jane', 'age': {'unit': 'year', 'value': 12}},
'b': {'name': 'John', 'age': {'unit': 'year', 'value': 14}},
'c': {'name': 'Jill', 'age': {'unit': 'year', 'value': 10}}
}
t = as_traversable(d, sep='.', map_char='^') # EZJD
# Normal key access
t['a'] # EZJD of {'name': 'Jane', 'age': {'unit': 'year', 'value': 12}}
# Path key access
t['a.name'] # 'Jane'
# Mapping across values
t['^.age.value'] # EZJD of [12, 14, 10]
List stuff
l = [[0, [1, 2]], [1, [2, 3]], [2, [3, 4]]]
t = as_traversable(l, sep='.', map_char='^') # EZJL
# Normal key access
t[0] # EZJL of [0, [1, 2]]
t['0'] # EZJL of [0, [1, 2]]
# Path key access
t['0.1.0'] # 1
# Mapping across values
t[':^.1.0'] # EZJL of [1, 2, 3]
t['1:-1^.1.0'] # EZJL of [2]
Other conveniences
l = [[0, [1, 2]], [1, [2, 3]], [2, [3, 4]]]
t = as_traversable(l, sep='.', map_char='^') # EZJL
# Normal key access
t[0] # EZJL of [0, [1, 2]]
t['0'] # EZJL of [0, [1, 2]]
# Path key access
t['0.1.0'] # 1
# Mapping across values
t[':^.1.0'] # EZJL of [1, 2, 3]
t['1:-1^.1.0'] # EZJL of [2]
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
ez-json-traverse-0.1.tar.gz
(4.6 kB
view hashes)
Built Distributions
Close
Hashes for ez_json_traverse-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81f74247308024bc3432e5a82ca2f15d1254f5e3d03228fdc50d180138926a2b |
|
MD5 | 1ef9518cdd2e708a590379966e0c6049 |
|
BLAKE2b-256 | 48e7d90799bf8a83ca833e38e93db0be963ce37d4e3e3d58923e1fa0a30a8249 |