How can I create a method UnmarshalJSON inside a struct, use json.Unmarshal inside without causing stack overflow?
package xapo
type Xapo struct {}
func (x Xapo) UnmarshalJSON(data []byte) error {
err := json.Unmarshal(data, &x)
if err != nil {
return err
}
fmt.Println("done!")
return nil
}
Can someone explain me why the stack overflow happens? Can it be fixed?
Thanks in advance.