Python functions for flattening a JSON object to a single dictionary of pairs, and unflattening that dictionary back to a JSON object
Project description
json-flatten
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 query string parameters.
For example:
>>> import json_flatten
>>> 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(_)
{'foo': {'bar': [1, True, None]}}
The top-level object passed to flatten()
must be a dictionary.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
json-flatten-0.3.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for json_flatten-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb3916ab43f85d362069cdfb8efaef9b20fc9440f9b931f0bbb7233e1508a2a7 |
|
MD5 | 5f2c74e4b0ac18f32d5ae8bed8530dd7 |
|
BLAKE2b-256 | 4a09276890accde4ec02ba332227587b5c77b3096fe528f9207f8dcd998c9273 |