cannot output a json encoded dict containing accents (noob inside)
- by user296546
Hi all,
here is a fairly simple example wich is driving me nuts since a couple of days. Considering the following script:
# -*- coding: utf-8 -*
from json import dumps as json_dumps
machaine = u"une personne émérite"
print(machaine)
output = {}
output[1] = machaine
jsonoutput = json_dumps(output)
print(jsonoutput)
The result of this from cli:
une personne émérite
{"1": "une personne \u00e9m\u00e9rite"}
I don't understand why their such a difference between the two strings.
i have been trying all sorts of encode, decode etc but i can't seem to be able to find the right way to do it. Does anybody has an idea ?
Thanks in advance.
Matthieu