Use json.dumps for the string handling instead.