Flask отключит автоматическое выход в ответ на Unicode JSONPython

Программы на Python
Гость
Flask отключит автоматическое выход в ответ на Unicode JSON

Сообщение Гость »


Я использую этот код для преобразования data frame with Unicode characters to JSON and add two extra items to it:

Код: Выделить всё

@app.route('/result1', methods = ['GET'])
def ReturnJSON():
if(request.method == 'GET'):
my_df=...
response = {
"count" : len(my_df),
"output" : "ok",
}
response['result']=my_df.to_json(orient='records', force_ascii=False)
return response
But I getting result like this with extra escape with \ like this:

Код: Выделить всё

{"count":10,"output":"ok","result":"[{\"Question\":\"-2 \\u062a\\...
Whereas should be like this:

Код: Выделить всё

{"count":10,"output":"ok","result":"[{"Question":"-2 \u062a\...
How to avoid auto escape in response?


Источник: https://stackoverflow.com/questions/781 ... icode-json

Вернуться в «Python»