I am making some api. Now I have problems when want to render some non english characters in json. This is example:
"Вук"
is show as "\u0412\u0443\u043a"
in json output.
I see lot of people is having this problem but I can not find solution.
This is peace of code:
response = {
"message":"user data",
"data":{
"email":user.username+"@"+user.emaildomain,
"username":user.username,
"domain":user.emaildomain,
"first_name":user.firstname,
"last_name":user.lastname,
"created_at":user.created_at,
"birthday":user.birthdate
},
"status":1
}
return jsonify({'response': response})
When I do print for example of user.firstname
I can see correct string.
Solution(?)
I replaced return jsonify(...)
with return json.dumps({'response': response}, ensure_ascii=False).encode('utf8')
.
Thanks to this answer:https://stackoverflow.com/a/18337754/1108279 now i got correct output.