You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from enum import Enum
class TestEnum(Enum):
KEY = 'value`
jsons.dumps(TestEnum.KEY) will result in "KEY" (Deserialization works correctly).
However, this is behavior is a little bit irrational in regards to what enum is (used to be in C :) ). Enums classically are used to map some "codenames" for binary values (like numbers 0, 1, 2, 3). Therefore the value of enum should be binary representation generally used in serialization and keys should be something assigned for it on the high level (on runtime/ in the codebase).
Update: just for a reference standard lib json module does not serialize Enum's at all.
The text was updated successfully, but these errors were encountered:
Given the following example Enum type:
jsons.dumps(TestEnum.KEY)
will result in"KEY"
(Deserialization works correctly).However, this is behavior is a little bit irrational in regards to what enum is (used to be in C :) ). Enums classically are used to map some "codenames" for binary values (like numbers 0, 1, 2, 3). Therefore the value of enum should be binary representation generally used in serialization and keys should be something assigned for it on the high level (on runtime/ in the codebase).
Update: just for a reference standard lib json module does not serialize Enum's at all.
The text was updated successfully, but these errors were encountered: