proposal: encoding/json: support json.Unmarshaler for decoding map keys #23455
Please answer these questions before submitting your issue. Thanks!
What did you do?
Unable to JSON marshal/unmarshal a custom primitive type as a map key unless the encoding Text interfaces are implemented instead of the JSON interfaces.
What did you expect to see?
The behaviour should be consistent for each implementation.
What did you see instead?
JSON unmarshalling fails if UnmarshalJSON is implemented instead of UnmarshalText. This is similar for marshalling.
The text was updated successfully, but these errors were encountered:
This seems to be enforced in the code on purpose:
And the godoc mentions the same:
So this is "working as intended". I am not sure why it is this way, though. It seems like
If you'd like to propose that