The TL;DR here is that if the standard encoding/json
machinery in
Go sees a null
in a JSON field or a nil
pointer in a Go field (of type
*T
), then it will not invoke the UnmarshalJSON()
/ MarshalJSON()
on
your type.
$ go run ./main.go
t1 = main.T{Shift:(*main.Point)(nil)} (nil stays nil, UnmarshalJSON() not invoked)