Converting Dictionary to JSON in python

json.dumps() returns the JSON string representation of the python dict. See the docs

r = {'is_claimed': 'True', 'rating': 3.5}json = json.dumps(r) file.write(str(r['rating']))