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.

I wonder if it's possible to correctly unmarshal Parent without overriding 
UnmarshalJSON for every member in the embedding chain? It's correctly the 
only way I know that can fix the issue, but it's very cumbersome, and there 
are cases where I only have control over Parent, but not Child and 
Grandchild,

Thanks. 

-- 
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/f58c9df8-6caa-4cc5-b55e-e940d1c7e248%40googlegroups.com.

Reply via email to