forked from platypush/platypush
Support for implicit serialization of Enum values in JSONAble.
This commit is contained in:
parent
a71017df33
commit
89d85baa6d
1 changed files with 4 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
import decimal
|
import decimal
|
||||||
import datetime
|
import datetime
|
||||||
|
from enum import Enum
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
import inspect
|
import inspect
|
||||||
|
@ -71,6 +72,9 @@ class Message:
|
||||||
if isinstance(obj, JSONAble):
|
if isinstance(obj, JSONAble):
|
||||||
return obj.to_json()
|
return obj.to_json()
|
||||||
|
|
||||||
|
if isinstance(obj, Enum):
|
||||||
|
return obj.value
|
||||||
|
|
||||||
# Don't serialize I/O wrappers/objects
|
# Don't serialize I/O wrappers/objects
|
||||||
if isinstance(obj, io.IOBase):
|
if isinstance(obj, io.IOBase):
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in a new issue