Skip to content

Allow to serialize enum by names #78

@souliane

Description

@souliane

Would be nice to add an option to serialize enum name instead of value.
I use such objects:

class FrequencyChoices(Enum):
    monthly = relativedelta.relativedelta(months=1)
    quarterly = relativedelta.relativedelta(months=3)

The values are not serializable so I need to serialize the name instead. Maybe the best would just be to rename the option ints_as_names and do not constraint its usage to enums storing int values. I can think about other applications where it could be preferable to serialize the name, even if the value is also serializable:

class CurrencyChoices(Enum):
    euro = "€"
    us_dollar = "$"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions