I have a problem with anonymity, which is currently hard for me ... I would like to develop several web services for my own use, and currently I am struggling with my damned French accents that will correctly display on my json outputs.
Here is my scenario: I am extracting a few rows from my database which I am inserting into the dict. What I want to do next is pass this dict to json.dumps and print the result.
The problem is this: lines containing accents are displayed as utf8, so for example, this gives me the following output: it should be émilie. It is depressing that if I print each line returned, the accents will be correctly displayed in my browser.
Questions:
- Is it okay to output such json output?
- How can I "just" convert a dict containing accents to json? (this is vital to me as other websites will work with my output).
Here is the test I am running.
from json import dumps as json_dumps
import json
machaine = "une personne émérite"
print(machaine)
output = {}
output[1] = machaine
output[2] = machaine
output[3] = machaine
jsonoutput = json_dumps(output)
print jsonoutput
source
share