Support for implicit serialization of Enum values in JSONAble.

This commit is contained in:
Fabio Manganiello 2023-03-26 03:43:04 +02:00
parent a71017df33
commit 89d85baa6d
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -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