sto usando Sockjs con Go, ma quando il client javascript invia json al server lo scappa e lo invia come un byte []. Sto cercando di capire come analizzare il json, in modo da poter leggere i dati. ma ottengo questo erroreCome rimuovere unmarshal una stringa JSON con escape in Go?
JSON: non può stringa unmarshal in valore Go di tipo main.Msg
come posso risolvere questo problema? html.UnescapeString() hanno nessun effetto:/
val, err := session.ReadMessage()
if err != nil {
break
}
var msg Msg
err = json.Unmarshal(val, &msg)
fmt.Printf("%v", val)
fmt.Printf("%v", err)
type Msg struct {
Channel string
Name string
Msg string
}
//Output
"{\"channel\":\"buu\",\"name\":\"john\", \"msg\":\"doe\"}"
json: cannot unmarshal string into Go value of type main.Msg
E 'anche interessante notare che html.UnescapeString() è per entità HTML come
gregghz