Skip to content

Commit e7cb43d

Browse files
authored
Bugfix: Support returning json serializable objects from an orchestrator function (#490)
1 parent 34112b1 commit e7cb43d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

azure/durable_functions/models/OrchestratorState.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from .utils.json_utils import add_attrib
77
from azure.durable_functions.models.actions.Action import Action
8+
from azure.functions._durable_functions import _serialize_custom_object
89

910

1011
class OrchestratorState:
@@ -75,15 +76,15 @@ def schema_version(self):
7576
"""Get the Replay Schema represented in this OrchestratorState payload."""
7677
return self._replay_schema.value
7778

78-
def to_json(self) -> Dict[str, Union[str, int]]:
79+
def to_json(self) -> Dict[str, Any]:
7980
"""Convert object into a json dictionary.
8081
8182
Returns
8283
-------
8384
Dict[str, Any]
8485
The instance of the class converted into a json dictionary
8586
"""
86-
json_dict: Dict[str, Union[str, int]] = {}
87+
json_dict: Dict[str, Any] = {}
8788
add_attrib(json_dict, self, '_is_done', 'isDone')
8889
if self._replay_schema != ReplaySchema.V1:
8990
add_attrib(json_dict, self, 'schema_version', 'schemaVersion')
@@ -113,4 +114,4 @@ def to_json_string(self) -> str:
113114
The instance of the object in json string format
114115
"""
115116
json_dict = self.to_json()
116-
return json.dumps(json_dict)
117+
return json.dumps(json_dict, default=_serialize_custom_object)

0 commit comments

Comments
 (0)