Use json.dumps to generate formatted json, then explicitly create a response object.