fix bug
This commit is contained in:
parent
62a28014bb
commit
1d1f59bab2
@ -5,11 +5,13 @@ from datetime import datetime
|
|||||||
from typing import TypeVar, Generic
|
from typing import TypeVar, Generic
|
||||||
from fastapi import status
|
from fastapi import status
|
||||||
import json
|
import json
|
||||||
|
from decimal import Decimal
|
||||||
class CustomJSONEncoder(json.JSONEncoder):
|
class CustomJSONEncoder(json.JSONEncoder):
|
||||||
def default(self, obj):
|
def default(self, obj):
|
||||||
if isinstance(obj, datetime):
|
if isinstance(obj, datetime):
|
||||||
return obj.strftime('%Y-%m-%d %H:%M:%S')
|
return obj.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
elif isinstance(obj, Decimal):
|
||||||
|
return float(obj)
|
||||||
return super().default(obj)
|
return super().default(obj)
|
||||||
|
|
||||||
class CustomJSONResponse(JSONResponse):
|
class CustomJSONResponse(JSONResponse):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user