From 89d85baa6d01bf7bb1b9444dec7aed42c7266687 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 26 Mar 2023 03:43:04 +0200 Subject: [PATCH] Support for implicit serialization of Enum values in JSONAble. --- platypush/message/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platypush/message/__init__.py b/platypush/message/__init__.py index 39095ea85f..1fe399417d 100644 --- a/platypush/message/__init__.py +++ b/platypush/message/__init__.py @@ -1,6 +1,7 @@ from abc import ABC, abstractmethod import decimal import datetime +from enum import Enum import io import logging import inspect @@ -71,6 +72,9 @@ class Message: if isinstance(obj, JSONAble): return obj.to_json() + if isinstance(obj, Enum): + return obj.value + # Don't serialize I/O wrappers/objects if isinstance(obj, io.IOBase): return None