Edit parts of json strings & files while keeping the orginal, inconsistent formating
Project description
pyJsonEdit
Edit parts of inconsistently formatted json.
It's just a bit slower that doint this by hand!
matcher
Now you can easly select nodes in json tree
syntax:
selector | action | node type |
---|---|---|
* | select all items in current node | - |
[n] | select n-th item of curent node | array |
{n} | select n-th item of curent node | object |
key | select node chilld by name | object |
"key" | select node chilld by name | object |
> | mark current node as seleced | - |
example 1:
key > [0]
this pattern will match one element by:
- selecting "key" element in root node (assuring that is an object)
- select first element in it (assumintg its and array)
example 2:
name > *
this pattern will match multiple elements by:
- selecting "name" element in root node (assuring that is an object)
- select all element in it
how to install
pip install --upgrade pyjsonedit
python module
$ import pyjsonedit
comand line
$ pyjsonedit --help
Usage: pyjsonedit [OPTIONS] PATTERN JSON
cli method for masking matching parts of json
Options:
--symbol TEXT
--color enable color output
--help Show this message and exit.
example: mask multiple nodes
$ pyjsonedit "quiz > * > q1 >*" DOC/example.json
{
"quiz": {
"sport": {
"q1": {
"question": XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,
"options": XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,
"answer": XXXXXXXXXXXXXXX
}
},
"maths": {
"q1": {
"question": XXXXXXXXXXX,
"options": XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,
"answer": XXXX
},
"q2": {
"question": "12 - 8 = ?",
"options": [
"1",
"2",
"3",
"4"
],
"answer": "4"
}
}
}
}
example: mask selected nodes
$ import pyjsonedit
$ pyjsonedit.string_match_mark("{'pass':123}","pass")
{'pass':XXX}
project stats
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
pyJsonEdit-0.0.21.tar.gz
(7.0 kB
view details)
Built Distribution
File details
Details for the file pyJsonEdit-0.0.21.tar.gz
.
File metadata
- Download URL: pyJsonEdit-0.0.21.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f07aa84e831cc2c027e57a0e70d06a8c26eabf610a54193215b84313bfb93aa1 |
|
MD5 | ebc9e8f856363bd2c92ebd177002ef4d |
|
BLAKE2b-256 | 3451078d0eb1450dc94be44b1894384dad2200ca6615bd487b6083fa4bbac13a |
Provenance
File details
Details for the file pyJsonEdit-0.0.21-py3-none-any.whl
.
File metadata
- Download URL: pyJsonEdit-0.0.21-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8235ea2f3b66385078386c737f1e2e3ba666a4e15d63791e50d119f8d4f517ca |
|
MD5 | ac928dee91f0437c1eed7ecd076013d2 |
|
BLAKE2b-256 | 1324bd87ef6315ed2f2cabfde473d8ded78d5178e859ae3ca2cdad1543bd9e22 |