Skip to content

Conversation

shaohuzhang1
Copy link
Contributor

fix: Workflow execution decimal cannot be serialized

return float(obj)
else:
return json.JSONEncoder.default(self, obj)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No significant issues were found in the provided code. However, there is a minor suggestion for improvement:

+        if isinstance(obj, decimal.Decimal):
+# Use float() to convert Decimal instead of str()
+            return float(obj)

This change ensures that when decimal.Decimal objects are encountered during serialization, they are converted to a floating-point number rather than converting them to strings. This might be more suitable depending on how you want to store or manipulate these numbers later in your application.

@shaohuzhang1 shaohuzhang1 merged commit fa1886a into main Feb 24, 2025
4 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@main@fix_decimal branch February 24, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant