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
Given a container struct with a map and an entity struct with custom Marshaler and Unmarshaler methods. The custom methods are defined using pointer references to the entity struct.
If the map values in the container struct are pointers to the entity struct everything works fine. If the map values are the actual entity structs then the MarshalJSON method isn't called.
Array values seem to work just fine with both pointers and objects.
UnmarshalJSON is defined on *Example, not Example, and map values are unaddressable.
Closing as working as intended.
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
AFAIK I'm using the latest release (or at least the latest snap release).
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Given a container struct with a map and an entity struct with custom
Marshaler
andUnmarshaler
methods. The custom methods are defined using pointer references to the entity struct.If the map values in the container struct are pointers to the entity struct everything works fine. If the map values are the actual entity structs then the
MarshalJSON
method isn't called.Array values seem to work just fine with both pointers and objects.
https://go.dev/play/p/jNsHN9rKAZt
What did you expect to see?
The map value cases for pointer and object should be the same.
What did you see instead?
The Object case doesn't seem to call the custom
MarshalJSON
for map values that are objects, but it works for array values that are objects.The text was updated successfully, but these errors were encountered: