Skip to main content

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-nodedump makes it easy to grep for patterns - this is a bit like gron, but is intended to make it easy to find patterns for creating transformations in your Python code.
  • jsonmason-jsdump is 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)

Source distribution for jsonmason 0.2.0
File Size Uploaded
jsonmason-0.2.0.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonmason 0.2.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page