From 30e5246cf5abe4df936a5bce52ae1d4e836cf153 Mon Sep 17 00:00:00 2001 From: Rushil Srivastava Date: Mon, 11 Jan 2021 03:11:35 -0800 Subject: [PATCH] Use FastAPI's built in jsonable_encoder --- fastapi_cache/coder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fastapi_cache/coder.py b/fastapi_cache/coder.py index 9914b24..43a177b 100644 --- a/fastapi_cache/coder.py +++ b/fastapi_cache/coder.py @@ -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 @@ -22,7 +23,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):