Metadata-Version: 2.5
Name: 314
Version: 0.0.3
Summary: Flatten nested JSON into dotted keys and rebuild it.
Project-URL: Homepage, https://pypi.org/project/314/
Author-email: lqxnjk <lqxnjk@qq.com>
License: MIT
License-File: LICENSE
Keywords: config,flatten,json,nested,unflatten
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# 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
