You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A key type implementing json.Unmarshaler cannot be unmarshaled. If key type implements TextUnmarshaler, JSON unmarshaling works as expected.
What did you expect to see?
This is probably a documentation issue. The documentation for json.Marshal does not require the key type to implement json.Marshaler, but the documentation for json.Unmarshal claims it should work. So I believe the documentation for json.Unmarshal should be corrected to not say a key type implementation should implement json.Unmarshaler.
The text was updated successfully, but these errors were encountered:
Go version
go version go1.22.1 linux/amd64
Output of
go env
in your module/workspace:What did you do?
The json unmarshal documentation claims that:
So I did this:
https://go.dev/play/p/bwYpWzHkfKC
What did you see happen?
A key type implementing
json.Unmarshaler
cannot be unmarshaled. If key type implementsTextUnmarshaler
, JSON unmarshaling works as expected.What did you expect to see?
This is probably a documentation issue. The documentation for
json.Marshal
does not require the key type to implementjson.Marshaler
, but the documentation forjson.Unmarshal
claims it should work. So I believe the documentation forjson.Unmarshal
should be corrected to not say a key type implementation should implementjson.Unmarshaler
.The text was updated successfully, but these errors were encountered: