314
English | 中文
把嵌套 JSON 拍平成点号键,并能原样还原。
安装
pip install 314
用法
from p314 import flatten_json, unflatten_json
doc = {"a": {"b": [{"c": 1}, {"c": 2}]}, "d": 3}
flatten_json(doc)
# {'a.b.0.c': 1, 'a.b.1.c': 2, 'd': 3}
unflatten_json(flatten_json(doc)) == doc # True
说明
包名以数字开头,导入名是 p314。列表用数字段表示,{"a": [{"b": 1}]} 变 {"a.0.b": 1};空容器保留空值,因此往返无损。unflatten_json 会把数字段还原成列表下标。
许可证
MIT
English
Flatten nested JSON into dotted keys and rebuild it.
Install
pip install 314
Usage
from p314 import flatten_json, unflatten_json
doc = {"a": {"b": [{"c": 1}, {"c": 2}]}, "d": 3}
flatten_json(doc)
# {'a.b.0.c': 1, 'a.b.1.c': 2, 'd': 3}
unflatten_json(flatten_json(doc)) == doc # True
Notes
The import name is p314 because the distribution starts with a digit. Lists use numeric segments, so {"a": [{"b": 1}]} becomes {"a.0.b": 1}. Empty containers are preserved, making the round trip lossless.
License
MIT
Metadata
Release files for 314 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| 314-0.0.4.tar.gz | 3.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 314-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.2 kB
Release files / 314-0.0.4.tar.gz
| Download URL | 314-0.0.4.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b251a1e755d2530067a0a066e6e487b92d537d2d86ae061c009411d6c651f5e
|
|
BLAKE2b-256 checksum How to use checksums |
28fd8180d3bd44f5fd4685ba794ce32bfd2a75ae544dd329d70391bd437e714f
|
| 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.4-py3-none-any.whl
| Download URL | 314-0.0.4-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d97588bd52d64f8549e7edd8339d98cf58dbb03d727388158482c28c2ba72848
|
|
BLAKE2b-256 checksum How to use checksums |
b2782095c96455c10550730188d8693a914e4b7c587ca620f84160c08bbd93a5
|
| 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.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.