On Tuesday, 31 December 2019 19:21:07 UTC+9, Glen Huang wrote: > > I want to unmarshal a struct that contains embedded structs: > > type Parent struct { > Child > P int > } > > > type Child struct { > Grandchild > C int > } > > > type Grandchild struct { > G int > } > > The problem is that Grandchild defines its own UnmarshalJSON method, and > that means Parent inherits it and breaks json.Unmarshal. >
The behaviour of encoding/json in your case seems odd to me. https://play.golang.org/p/asKPyzul9hl Is there a good reason why it does this? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/3844cb54-576c-4b84-b810-2c2fd1a0851f%40googlegroups.com.