Skip to content

Bugfix: Support returning json serializable objects from an orchestrator function #490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions azure/durable_functions/models/OrchestratorState.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from .utils.json_utils import add_attrib
from azure.durable_functions.models.actions.Action import Action
from azure.functions._durable_functions import _serialize_custom_object


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

def to_json(self) -> Dict[str, Union[str, int]]:
def to_json(self) -> Dict[str, Any]:
"""Convert object into a json dictionary.

Returns
-------
Dict[str, Any]
The instance of the class converted into a json dictionary
"""
json_dict: Dict[str, Union[str, int]] = {}
json_dict: Dict[str, Any] = {}
add_attrib(json_dict, self, '_is_done', 'isDone')
if self._replay_schema != ReplaySchema.V1:
add_attrib(json_dict, self, 'schema_version', 'schemaVersion')
Expand Down Expand Up @@ -113,4 +114,4 @@ def to_json_string(self) -> str:
The instance of the object in json string format
"""
json_dict = self.to_json()
return json.dumps(json_dict)
return json.dumps(json_dict, default=_serialize_custom_object)