Stats

Contributors: 1 Sunday, March 27, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Creating JSON from Python dict

Example

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}'