Reputation: 8764
I'm trying to save a variable with double quotes in python, because I need to pass the double quoted JSON to a template and single quotes wont work with what I'm doing. So I set the variable in python to:
json = {
"auth": {
"key": "auth-code-here"
},
"template_id": "id-here",
"redirect_url": "url-here",
}
But immediate in python, it's saved as
{'redirect_url': 'url-here', 'template_id': 'id-here', 'auth': {'key': 'auth-code-here'}}
Is there a way I can save it as double quoted? Or will I need to process this in a django template to replace the single quotes for double quotes?
Thanks!
Upvotes: 7
Views: 6352
Reputation: 17564
You should use a JSON module to do that. To Python, double- and single-quotes are interchangeable.
Python has JSON abilities built in.
Upvotes: 21