I'm new to Go, and having trouble figuring out how to print out a JSON I've created. I'm using "encoding/json" and am getting a []byte returned. However when I go to print this out I get:
cannot use json_msg (type []byte) as type string in function argument
After receiving this I've tried to convert the []byte array to a string or an empty interface. However I can't seem to get it to work. Any ideas? Relevant code below:
type Message struct {
Id int
Name string
}
for _, row := range rows {
m := Message{row.Int(0), row.Str(1)}
json_msg, err := json.Marshal(m)
if err == nil {
panic(err)
}//if
//tried below to print out a interface, didn't work either
//var f interface{}
//err = json.Unmarshal(json_msg, &f)
fmt.Fprintf(c.ResponseWriter, json_msg)
}//for