私はFlask-SQLAlchemyを使用してこのモデルを持っています:
class Menu(Document, db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(80), unique=True, index=True)
price = db.Column(db.Numeric)
そして、このモデルに Flask-Restless を使用して API を作成できます。問題は、API URL から HTTP GET を実行するときです。
File "/usr/lib/python2.6/json/encoder.py", line 344, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: Decimal('10000.0000000000') is not JSON serializable
問題は、JSON エンコーダーが価格 (数値列タイプ) にマップされる 10 進数値をエンコードできないことは明らかです。カスタム JSON エンコーダーを使用して Flask-Restless を有効にする回避策はありますか?