[New-bugs-announce] [issue41569] json.JSONEncoder.default should be called for dict keys as well

David Byrne report at bugs.python.org
Mon Aug 17 13:42:21 EDT 2020


New submission from David Byrne <david.byrne222 at gmail.com>:

Sub-classing and overriding json.JSONEncoder.default allows users to create custom serialisation for objects that can’t otherwise be serialized. However, this method is only called for dictionary values such that dictionary supported keys (i.e. hashable types) can not be fully utilized. Calling .default on keys as well as values allows users to to fully utilize json for all dict supported types. 

See https://stackoverflow.com/questions/63393059/json-dump-not-calling-default-or-cls for example

----------
components: Library (Lib)
messages: 375561
nosy: david.byrne222
priority: normal
severity: normal
status: open
title: json.JSONEncoder.default should be called for dict keys as well
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41569>
_______________________________________


More information about the New-bugs-announce mailing list