@@ -685,8 +685,9 @@ def orjson_dumps(obj: Any, **kwargs) -> str:
685685 """Serialize obj to a JSON string, using orjson when available.
686686
687687 Translates common json.dumps kwargs (indent, sort_keys) into orjson
688- option flags. Falls back to stdlib json if orjson is not installed,
689- an unsupported kwarg is passed, or orjson raises TypeError.
688+ option flags. Falls back to ``json_dumps`` (which has the
689+ ``serializers.serialize`` default) if orjson is not installed, an
690+ unsupported kwarg is passed, or orjson raises TypeError.
690691
691692 Args:
692693 obj: The object to serialize.
@@ -698,7 +699,7 @@ def orjson_dumps(obj: Any, **kwargs) -> str:
698699 try :
699700 import orjson # pyright: ignore[reportMissingImports]
700701 except ImportError :
701- return json . dumps (obj , ** kwargs )
702+ return json_dumps (obj , ** kwargs )
702703
703704 option = 0
704705 if kwargs .pop ("indent" , None ):
@@ -709,13 +710,14 @@ def orjson_dumps(obj: Any, **kwargs) -> str:
709710
710711 if kwargs :
711712 # Fall back to stdlib json for unsupported kwargs.
712- return json . dumps (obj , ** kwargs )
713+ return json_dumps (obj , ** kwargs )
713714
714715 try :
715716 return orjson .dumps (obj , option = option or None ).decode ()
716717 except TypeError :
717- # Fallback for types orjson can't handle (e.g. int > 64-bit).
718- return json .dumps (obj )
718+ # Fallback for types orjson can't handle (e.g. int > 64-bit, or
719+ # custom types). ``json_dumps`` carries the serializer default.
720+ return json_dumps (obj )
719721
720722
721723def orjson_loads (data : str | bytes ) -> Any :
0 commit comments