As stated in the encoding/json package documentation,
Marshal traverses the value v recursively. If an encountered value implements the Marshaler interface and is not a nil pointer, Marshal calls its MarshalJSON method to produce JSON.
Where exactly in the code is this test performed?
In another terms, how does encoding/json check if a value v of type t implements the Marshaller interface?