Serialisation of complex JSON to URL GET parameters, and reverse

View the Project on GitHub guidj/jsonuri-py


This package helps you convert Python dictionaries into an HTTP GET request parameters, and vice-versa.

An example of a practical application would be to send JSON data over HTTP GET, e.g. to a static resource small.png, and harvest the data from access logs instead of running real-time data collection.

Note: You should avoid send sensitive information using this mechanism, or at least ensure you send your data over SSL.

Equivalent libs/packages:

Language Repo
JavaScript https://github.com/guidj/jsonuri-js



>>> import json
>>> import urllib.parse
>>> from jsonuri import jsonuri
>>> jsonuri.serialize(json.loads('{"age": "31", "name": "John", "account": {"id": 127, "regions": ["US", "SG"]}}'))
>>> jsonuri.serialize(json.loads('{"age": "31", "name": "John", "account": {"id": 127, "regions": ["US", "SG"]}}'), encode=False)


>>> string = "account:regions[0]=US&account:regions[1]=SG&account:id=127&age=31&name=John"
>>> jsonuri.deserialize(string)
{'account': {'regions': ['US', 'SG'], 'id': '127'}, 'age': '31', 'name': 'John'}


The package was not designed to process HTML form data, specifically multi-value variables, i.e. from select attributes. Though if you convert the data to a JSON/JavaScript object, that should work.