mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-25 13:07:53 +00:00
Use FastAPI's built in jsonable_encoder
This commit is contained in:
committed by
GitHub
parent
9157412d6a
commit
30e5246cf5
@@ -3,6 +3,7 @@ import json
|
|||||||
import pickle # nosec:B403
|
import pickle # nosec:B403
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from fastapi.encoders import jsonable_encoder
|
||||||
|
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ class JsonEncoder(json.JSONEncoder):
|
|||||||
elif isinstance(obj, Decimal):
|
elif isinstance(obj, Decimal):
|
||||||
return {"val": str(obj), "_spec_type": "decimal"}
|
return {"val": str(obj), "_spec_type": "decimal"}
|
||||||
else:
|
else:
|
||||||
return super().default(obj)
|
return jsonable_encoder(obj)
|
||||||
|
|
||||||
|
|
||||||
def object_hook(obj):
|
def object_hook(obj):
|
||||||
|
|||||||
Reference in New Issue
Block a user