Skip to content

Commit a50c88a

Browse files
Move model_dump check outside of if statement
1 parent 9038f8f commit a50c88a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

essentials/json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def default(self, obj: Any) -> Any:
2020
try:
2121
return json.JSONEncoder.default(self, obj)
2222
except TypeError:
23+
if hasattr(obj, "model_dump"):
24+
return obj.model_dump()
2325
if hasattr(obj, "dict"):
24-
if hasattr(obj, "model_dump"):
25-
return obj.model_dump()
2626
return obj.dict()
2727
if isinstance(obj, time):
2828
return obj.strftime("%H:%M:%S")

0 commit comments

Comments
 (0)