Skip to content

coerce_keys option #29

@lidatong

Description

@lidatong

The py-to-json conversion table specifies that dict keys must be of a basic type: str, int, float, bool or None

However in practical usage, it's quite convenient to have objects as dictionary keys (especially, in lieu of data classes, leveraging the frozen=True option). Having the basic type restriction on keys makes encoding unnecessarily boilerplate-y.

Creating this issue for a potential coerce_keys kwarg to add to the public api. This gives the user the option of supplying a function to coerce non-basic type keys into a str.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions