json: cannot unmarshal object into a Go struct field

PROBLEM

Simplify Complexity
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
}

--

--

Simplify Complexity

Golang, Distributed Systems, File Systems, Python, C/C++, Linux