314


توضیحات

把嵌套 JSON 拍平成点号键,并能原样还原。
ویژگی مقدار
سیستم عامل OS Independent
نام فایل 314-0.0.4
نام 314
نسخه کتابخانه 0.0.4
نگهدارنده []
ایمیل نگهدارنده []
نویسنده -
ایمیل نویسنده lqxnjk <lqxnjk@qq.com>
آدرس صفحه اصلی -
آدرس اینترنتی https://pypi.org/project/314/
مجوز MIT
# 314 [English](#english) | 中文 把嵌套 JSON 拍平成点号键,并能原样还原。 ## 安装 ```console pip install 314 ``` ## 用法 ```python 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 --- <a id="english"></a> ## English Flatten nested JSON into dotted keys and rebuild it. ## Install ```console pip install 314 ``` ## Usage ```python 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


زبان مورد نیاز

مقدار نام
>=3.10 Python


نحوه نصب


نصب پکیج whl 314-0.0.4:

    pip install 314.whl


نصب پکیج tar.gz 314-0.0.4:

    pip install 314.tar.gz