CLI tool to view json tree / structure
cat input.json
# {"a": 1, "b": [{"c": 3}]}
python -m jsontp -i input.json -v
# root -> a
# root -> b
# root -> b -> [0] -> c
python -m jsontp -i input.json -k c
# root -> b -> [0] -> c
Install
pip install jsontp
# or
pip install git+https://github.com/ames0k0/jsontp
CLI Arguments
CLI tool to view json tree / structure
options:
-h, --help show this help message and exit
-i I [i]nput filepath
-o O [o]utput filepath
-v [V] [v]view json tree
-k K [k]ey to search
-t T [t]ree to `-o` the data from
-l L [l]imit stdout
-il IL [i]tems [l]imit stdout
-fk FK [f]ilter stdout by `key`
-fv FV [f]ilter stdout by `value`
Usage Example :: CLI
# View tree / structure with array items limit 1
python -m jsontp -i input.json -v -il 1
# Search for `key` (-k), filter by `key` (-fk)
python -m jsontp -i input.json -k id -fk user
# Search for `key` (-k), filter by `key` (-fk), print the value for `tree`
python -m jsontp -i input.json -k id -fk user -o '*'
# Print the value for `tree` (NOTE: `-o output.json` - to dump a value)
python -m jsontp -i input.json -t 'root -> props -> ... -> user' -o '*'
Usage Example :: API (Experimental)
from jsontp import JsonTreeParser
from jsontp.utils import FileIO
from jsontp.config import Key
file_io = FileIO(src="input.json")
file_data = file_io.load()
pdt = JsonTreeParser(data=file_data)
pdt_tree = pdt.tree_by_key_or_view(key="user", result_to=Key.SAVE)
data_for_tree = pdt.data_by_tree(tree=next(pdt_tree))
file_io.dump(data=data_for_tree, dst="output.json")
License :: MIT
Copyright (c) 2022,2024 ames0k0
Metadata
Release files for jsontp 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jsontp-1.2.0.tar.gz | 5.5 kB | Without provenance | Details for jsontp-1.2.0.tar.gz |
Release files / jsontp-1.2.0.tar.gz
| Download URL | jsontp-1.2.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e840aa03a5b101740f2a08a973d8803d2ef7472c19fb2e4068289b5c7b49490
|
|
BLAKE2b-256 checksum How to use checksums |
631f9f49271654c5cc2f68bed759ae5cc76b49ecdc7a8db95314141e8a235cb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for jsontp 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.