import json d = { 'foo': 'bar', 'alice': 1, 'wonderland': [1, 2, 3] } json.dumps(d)
The above snippet will return the following:
'{"wonderland": [1, 2, 3], "foo": "bar", "alice": 1}'