I am trying to display some json with cyrillic characters. But, for example, instead of Cyrillic A, I get the code ascii - \ u0410 And this is not the json encoder that breaks the material. If I try to output my own ls variable, it already displays the ascii view. I tried to encode-decode it in different ways, but in the end I got a compromise.
Here is the code:
def grades(request): grades = Grades.objects.all() Status = 0 Message = 'No records' dataset = {} Response = {} Response['Type'] = 'class' Response['Data'] = {} x = '' if grades.exists() : Status = 1 Message = 'Success' ls = list() for grade in grades: dataitem = {} dataitem['id'] = grade.id dataitem['name'] = u'' + str(grade.grade) + grade.letter
Here is the result:
{"Status": 1, "Message": "Success", "Response": {"Data": [{"id": 1, "name": "1\u0410"}, {"id": 2, "name": "1\u0411"}, {"id": 3, "name": "1\u0412"}, {"id": 4, "name": "2\u0410"}, {"id": 5, "name": "2\u0411"}, {"id": 6, "name": "2\u0412"}], "Type": "class"}}
source share