ashb commented on code in PR #27540:
URL: https://github.com/apache/airflow/pull/27540#discussion_r1020078064


##########
airflow/utils/json.py:
##########
@@ -123,3 +136,89 @@ def dumps(self, obj, **kwargs):
 
     def loads(self, s: str | bytes, **kwargs):
         return json.loads(s, **kwargs)
+
+
+# for now separate as AirflowJsonEncoder is non-standard
+class XComEncoder(json.JSONEncoder):
+    """This encoder allows serializes any object that has attr."""
+
+    def default(self, o: object) -> dict:
+        from airflow.serialization.serialized_objects import BaseSerialization
+
+        if hasattr(o, "serialize"):
+            classname = o.__module__ + "." + o.__class__.__name__
+            version = getattr(o.__class__, "version", DEFAULT_VERSION)
+            return {
+                CLASSNAME: classname,
+                VERSION: version,
+                DATA: getattr(o.__class__, "serialize")(o)

Review Comment:
   Shouldn't this be
   
   ```suggestion
                   DATA: getattr(o, "serialize")()
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to