Skip to content
Python functions for flattening a JSON object to a single dictionary of pairs, and unflattening that dictionary back to a JSON object
Branch: master
Clone or download
Latest commit 92879c9 Jun 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Switch tests to use pytest Jun 22, 2019
.gitignore README and setup.py Jun 22, 2019
README.md README and setup.py Jun 22, 2019
json_flatten.py Fix for Python 3 Jun 22, 2019
setup.py Switch tests to use pytest Jun 22, 2019
test_json_flatten.py Switch tests to use pytest Jun 22, 2019

README.md

json-flatten

PyPI CircleCI License

Python functions for flattening a JSON object to a single dictionary of pairs, and unflattening that dictionary back to a JSON object.

Useful if you need to represent a JSON object using a regular HTML form or transmit it as a set of querystring parameters.

For example:

>>> json_flatten.flatten({"foo": {"bar": [1, True, None]}})
{'foo.bar.0$int': '1', 'foo.bar.1$bool': 'True', 'foo.bar.2$none': 'None'}
>>> json_flatten.unflatten(d)
{'foo': {'bar': [1, True, None]}}
You can’t perform that action at this time.