Metadata-Version: 2.5
Name: 314
Version: 0.0.2
Summary: Flatten nested JSON into dotted keys and rebuild it.
Project-URL: Homepage, https://github.com/lqxnjk/314
Author: lqxnjk
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

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:

```python
from p314 import flatten_json
```

## Install

```console
pip install 314
```

## Usage

```python
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
