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.
The py-to-json conversion table specifies that dict keys must be of a basic type:
str,int,float,boolorNoneHowever in practical usage, it's quite convenient to have objects as dictionary keys (especially, in lieu of data classes, leveraging the
frozen=Trueoption). Having the basic type restriction on keys makes encoding unnecessarily boilerplate-y.Creating this issue for a potential
coerce_keyskwarg to add to the public api. This gives the user the option of supplying a function to coerce non-basic type keys into astr.