jsonmason - deconstruct JSON into assignments, mangle them at will, and reconstitute JSON from the assignments.
Project description
JsonMason
What
A utility/library for transforming an object into an editable stream, and reconstructing an object from that stream. To be precise:
- Transform an an object of acyclic nested collections into an iterable of assignment operations (deconstruction)
- Create an object of acyclic nested collections from an iterable of assignment operations (reconstruction)
Why
Deconstructing only to reconstruct does not seem very useful in itself. The power is in operating on the intermediary format — the iterable of nodes lends itself well to pattern matching, transformations, and other forms of computation.
How
In the shell
If you've installed this package (eg pipx install jsonmason), then you should have two executables on your $PATH. Both accept JSON on standard input, and print the deconstruction of that JSON on standard output.
jsonmason-nodedumpmakes it easy togrepfor patterns - this is a bit likegron, but is intended to make it easy to find patterns for creating transformations in your Python code.jsonmason-jsdumpis even more like , as it prints JS-style assignments that can be pasted straight into a JS console.
In Python code
The basics:
from jsonmason import deconstruct, reconstruct
In addition there is a module attrdict which makes it possible to address dicts by "dot-attribute-paths" (as in JS).
from jsonmason import AttrDict
For examples, have a look at the module docstrings:
Testing
Run test.py.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsonmason-0.2.0.tar.gz.
File metadata
- Download URL: jsonmason-0.2.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80eef1e45427e581d49ff4521c8ea236c4c3dfd3884ac411f902ec1e22e69c89
|
|
| MD5 |
342b86f92444b4d913d2c04fc5117a24
|
|
| BLAKE2b-256 |
a59a15e775d25b82c31e6e7d900150e1e09e5539ec2ece08fa66a57accee5eae
|
File details
Details for the file jsonmason-0.2.0-py3-none-any.whl.
File metadata
- Download URL: jsonmason-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91a3db8329ec8324ef09b28f2e3986914b3b9117b3fea7ca0567622f40e21905
|
|
| MD5 |
f2a7304b3dde71055448167fdb91726d
|
|
| BLAKE2b-256 |
c35236b17f9d4d075b3e231996207b14045cc7a6477b2b27e9aad0a39358d202
|