I need to dump Thai language but when me dump don't show I'm use
library
from flask_restful import Api, Resource
from flask import Flask , jsonify
import json
datainjson >>`{"tim": [{"age":19,"gender":"ชาย"}],
"bill": [{"age": 70,"gender":"male"}]}`
class Helloword(Resource):
def get(self,name):
url = './testCode/json/myfilejson.json'
with open(url, encoding="utf8") as f:
names = json.load(f)
return json.dumps(names[name],indent=4,ensure_ascii=False)
api.add_resource(Helloword,"/helloword/<string:name>")
this is url >> http://localhost:5000/helloword/tim
output
"[\n {\n \"age\": 19,\n \"gender\": \"\u0e40\u0e1e\u0e28\u0e0a\u0e32\u0e22\"\n }\n]"
Expect(me need)
[
{
"age": 19,
"gender": "เพศชาย"
}
]
But when me use nomall api is ok can show word Thai
@app.route('/Correct')
def Correct():
with open(url, encoding="utf8") as f:
obj = json.load(f)
return json.dumps(obj,ensure_ascii=False)
But I would like to do the first type, I want to check (id) and response value
Thank you