save a dict to json python

JavaScript
import json

with open('data.json', 'w') as fp:
    json.dump(data, fp)
Source

Also in JavaScript: