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

Notifications You must be signed in to change notification settings

xshahbazintel/json-flatten

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-flatten

PyPI Changelog Tests 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 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]}}

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%