I\'ve got a web socket connection that sends different types of messages in a JSON object, and I want to unmarshal the contents into some known structs. To do this, I figur
One solution is to partially unmarshal the data by unmarshalling the values into a json.RawMessage instead of an interface{}
var myMap map[string]json.RawMessage
Later in the switch, which still is required, you do not need to marshal. Just do:
err = json.Unmarshal(v, &myAck)
Playground: https://play.golang.org/p/NHd3uH5e7z