I get an error message:
json.Unmarshal undefined (type interface {} has no field or method Unmarshal)
trying to convert a piece of json byte into a generic interface type {}. I am reading docs for encoding/json and they give an example showing that this is valid. What gives?
package main import ( "encoding/json" "fmt" "io/ioutil" ) func main() { var json interface{} data, _ := ioutil.ReadFile("testMusic.json") json.Unmarshal(data, &json) m := json.(map[string]interface{}) fmt.Printf("%+v", m) }
source share