This is my simple flask-restful api. To get a name which is in Japanese. When I run this I get
{"name":"\u5317\u6d77\u9053"}
but expected
{"name":"北海道"}
Below is the code.
class Prefecture(Base):
id=Column(Integer, primary_key=True)
name=Column(String)
class PrefectureSchema(SQLAlchemyAutoSchema):
class Meta:
ordered:True
model =Prefecture
class PrefectureApi(Resource):
def get(self):
schema=PrefectureSchema(many=True)
values = Prefecture.query.all()
return {schema.dump(values)
How to I change the unicode to characters before dumping it.I would like to continue using marshamallow as I would like to use the field.nested for my relationships. I tried to add configuration below but it didn't work.
app.config['JSON_AS_ASCII']=False
Adding
Saved me lots of headache.