title: How to unmarshal an escaped JSON string
body: <p>I am using Sockjs with Go, but when the JavaScript client send json to the server it escapes it, and send's it as a []byte. I'm trying to figure out how to parse the json, so that i can read the data. but I get this error.</p>
  <blockquote>
  <p>json: cannot unmarshal string into Go value of type main.Msg</p>
  </blockquote>
  <p>How can I fix this? <code>html.UnescapeString()</code> has no effect.</p>
  <pre><code>val, err := session.ReadMessage()
  if err != nil {
  break
  }
  var msg Msg
  
  err = json.Unmarshal(val, &amp;msg)
  
  fmt.Printf(&quot;%v&quot;, val)
  fmt.Printf(&quot;%v&quot;, err)
  
  type Msg struct {
      Channel string
      Name    string
      Msg     string
  }
  </code></pre>
  <pre><code>//Output
  &quot;{\&quot;channel\&quot;:\&quot;buu\&quot;,\&quot;name\&quot;:\&quot;john\&quot;, \&quot;msg\&quot;:\&quot;doe\&quot;}&quot;
  json: cannot unmarshal string into Go value of type main.Msg
  </code></pre>