json: cannot unmarshal object into a Go struct field
PROBLEM
1 min readJan 28, 2022
--
json: cannot unmarshal object into Go struct field
CODE
package mainimport (
"encoding/json"
"fmt"
)// DTO object
type mould struct {
Particle tiny
}type tiny interface {
GetName() string
}// Implement the interface
type speck struct {
Name string `json:"name"`
}func (s *speck) GetName() string {
return s.Name
}