只需重写flask.json中的JSONEncoder方法
from flask import Flask as _Flask
from flask.json import JSONEncoder as _JSONEncoderclass JSONEncoder(_JSONEncoder):def default(self, o):import decimalif isinstance(o, decimal.Decimal):return float(o)super(JSONEncoder, self).default(o)class Flask(_Flask):json_encoder = JSONEncoder