Skip to main content

JSON Expand-O-Matic

Expand a dict into a collection of subdirectories and json files or contract (un-expand) the output of expand() into a dict.

Overview

Construct

expandomatic = JsonExpandOMatic(path=data_path, logger=logger)

Expand -- become or make larger or more extensive.

data = { ... }

data_path = sys.argv[1] if len(sys.argv) > 1 else '.'

Create {data_path}/root.json and {data_path}/root/...

expandomatic.expand(data)

Create {data_path}/foo.json and {data_path}/foo/...

expandomatic.expand(foo, root_element='foo')

Warning: expand() is destructive unless `preserve=True`

Contract -- decrease in size, number, or range.

data = expandomatic.contract()

Or use jsonref

import jsonref
with open(f'{data_path}/root.json') as f:
    data = jsonref.load(f, base_uri=f'file://{os.path.abspath(data_path)}/')

Quick Start

Setup wrapper scripts:

./wrapper.sh

Install for development:

./tox.sh

Do a thing:

rm -rf output
./expand.sh output tests/testresources/actor-data.json 2>&1 | tee log.txt
find output -type f | sort

Do another thing:

rm -rf output
./expand.sh output tests/testresources/actor-data.json '[{"/root/actors/.*": ["/[^/]+/movies/.*"]}]' 2>&1 | tee log.txt
find output -type f | sort

Testing

Install & use tox:

./tox.sh

Update requirements.txt and dev-requirements.txt:

./tox.sh -e deps

Reformat the code to make it pretty:

./tox.sh -e fmt

Manually run the commands:

./wrapper.sh
./expand.sh output tests/testresources/actor-data.json
./contract.sh output | jq -S . > output.json
ls -l output.json tests/testresources/actor-data.json
cmp output.json <(jq -S . tests/testresources/actor-data.json)

Metadata

Release files for json-expand-o-matic 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for json-expand-o-matic 0.2.4
File Size Uploaded Provenance Actions
json_expand_o_matic-0.2.4.tar.gz 17.4 kB Without provenance Details for json_expand_o_matic-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for json-expand-o-matic 0.2.4
File Interpreter ABI Platform Actions
json_expand_o_matic-0.2.4-py3-none-any.whl Python 3 none any Details for json_expand_o_matic-0.2.4-py3-none-any.whl

Total release size: 31.7 kB

Release files / json_expand_o_matic-0.2.4.tar.gz

Download URL json_expand_o_matic-0.2.4.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
248f45562f00fbf41a6601f330293d03422f366716e11d23365c5b951d436b06
BLAKE2b-256 checksum
How to use checksums
23a9388d3fbf7cc202e1107cbe8f4e7fe7a207a4b6cf24c865a06c066fa3e6bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / json_expand_o_matic-0.2.4-py3-none-any.whl

Download URL json_expand_o_matic-0.2.4-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd15d0c8af53d2f84eba933631892be03fe596c60b1bc0f2f4440eb47e8693a7
BLAKE2b-256 checksum
How to use checksums
7ab7a235eeff6b3201f24a5716a61647e9efce21ae8f70f748358be47a457f00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Security for json-expand-o-matic 0.2.4

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.

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