@John , json-, indirect(v reflect.Value, decodingNull bool) line 442-483.
// v ,
// , .
// Unmarshaler, .
// decodingNull , , nil.
json.Unmarshaler, encoding.TextUnmarshaler v.
v , , , v json.Unmarshaler/encoding.TextUnmarshaler . nil unmarshaller, , B unmarshaller .v , , v json.Unmarshaler/encoding.TextUnmarshaler . , v nil, v.
Embedded
type Embedded struct {
A struct {
B struct {
*P
} `json:"b"`
} `json:"a"`
}
, "b":{"name":"bob"} B, B , (1) . unmarshaller nil, . - json B.
Embedded
type Embedded struct {
A struct {
*B struct {
P
} `json:"b"`
} `json:"a"`
}
B , (2) . struct{*P} B, , B unmarshaller, .
type Embedded struct {
A struct {
*B struct {
*P
} `json:"b"`
} `json:"a"`
}
, P ,
e := Embedded{}
e.A.B = &struct{ *P }{P: &P{}}
, (2) &struct{*P}{} B, unmarshaller B.P == nil. json B.P unmarshall.
:
, , , .