Python Saving JSON Files as UTF-8

json, python, utf-8, utf8-decode

Solution

Set `ensure_ascii` to `False`:

>>> print json.dumps(x, ensure_ascii=False)
{"some_key": "Enviar invitación privada"}

Problem

I'm trying to output some UTF-8 characters to a JSON file. When I save the file they're being written like this: {"some_key": "Enviar invitaci\u00f3n privada"} The above is valid and works. When I load the file and print 'some_key' it displays "Enviar invitación privada" in the terminal. Is there anyway to write the JSON file with "some_key" as the encoded version, like this? {"some_key": "Enviar invitación privada"}

Original source

Related problems