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.
Release files for jsonmason 0.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 | |
|---|---|---|---|
| jsonmason-0.2.0.tar.gz | 6.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jsonmason-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.4 kB
Release files / jsonmason-0.2.0.tar.gz
| Download URL | jsonmason-0.2.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80eef1e45427e581d49ff4521c8ea236c4c3dfd3884ac411f902ec1e22e69c89
|
|
BLAKE2b-256 checksum How to use checksums |
a59a15e775d25b82c31e6e7d900150e1e09e5539ec2ece08fa66a57accee5eae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / jsonmason-0.2.0-py3-none-any.whl
| Download URL | jsonmason-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91a3db8329ec8324ef09b28f2e3986914b3b9117b3fea7ca0567622f40e21905
|
|
BLAKE2b-256 checksum How to use checksums |
c35236b17f9d4d075b3e231996207b14045cc7a6477b2b27e9aad0a39358d202
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|