Skip to main content

314

Flatten a nested JSON document into {"dotted.key": value} pairs, and rebuild it exactly. Handy for diffing configs, indexing documents and diffing API responses line by line.

The import name is p314 because a Python module cannot start with a digit:

from p314 import flatten_json

Install

pip install 314

Usage

from p314 import flatten_json, unflatten_json

doc = {"a": {"b": [{"c": 1}, {"c": 2}]}, "d": 3}

flat = flatten_json(doc)
# {'a.b.0.c': 1, 'a.b.1.c': 2, 'd': 3}

unflatten_json(flat) == doc      # True

Rules

Input Output key
nested dict parent.child
list element parent.0, parent.1, ...
scalar at root the empty key

Empty containers are kept as empty values so the round trip is lossless. unflatten_json turns numeric segments back into list indices.

License

MIT

Metadata

Release files for 314 0.0.2

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

Source distribution (sdist)

Source distribution for 314 0.0.2
File Size Uploaded Provenance
314-0.0.2.tar.gz 3.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for 314 0.0.2
File Interpreter ABI Platform
314-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 6.8 kB

Release files / 314-0.0.2.tar.gz

Download URL 314-0.0.2.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a7016137d6f88201e6a8be5e43ea37ea3bdf8d4bbd6b3308d693dc02ad3abf3d
BLAKE2b-256 checksum
How to use checksums
ae21e506b71bc9e900b12bb618c28642ece7b195c11c59213392428346db38dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / 314-0.0.2-py3-none-any.whl

Download URL 314-0.0.2-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f91d026e4cfdf50aaac294293c4f50699f642d92b4229f382f923d853c9fa4d
BLAKE2b-256 checksum
How to use checksums
ed2f3014192bd85e7525239a36c3350bafcb957ce3df5ea1dfcbd98365308641
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for 314 0.0.2

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