mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-24 20:47:54 +00:00
Merge pull request #8 from rushilsrivastava/patch-2
Use FastAPI's built in jsonable_encoder
This commit is contained in:
@@ -3,6 +3,7 @@ import json
|
||||
import pickle # nosec:B403
|
||||
from decimal import Decimal
|
||||
from typing import Any
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
|
||||
import dateutil.parser
|
||||
|
||||
@@ -25,7 +26,7 @@ class JsonEncoder(json.JSONEncoder):
|
||||
elif isinstance(obj, Decimal):
|
||||
return {"val": str(obj), "_spec_type": "decimal"}
|
||||
else:
|
||||
return super().default(obj)
|
||||
return jsonable_encoder(obj)
|
||||
|
||||
|
||||
def object_hook(obj):
|
||||
|
||||
Reference in New Issue
Block a user