type MyStruct struct {
Value json.RawMessage `json:"value"`
}
var resp *http.Response
if resp, err = http.DefaultClient.Do(req); err == nil {
if resp.StatusCode == 200 {
var buffer []byte
if buffer, err = ioutil.ReadAll(resp.Body); err == nil {
mystruct = &MyStruct{}
err = json.Unmarshal(buffer, mystruct)
}
}
}
fmt.Println(string(mystruct.Value))
it produces something like:
\u003Chead>\n \u003C/head>\n \u003Cbody>
Doc at: http://golang.org/pkg/encoding/json/#Unmarshal
says: When unmarshaling quoted strings, invalid UTF-8 or invalid UTF-16 surrogate pairs are not treated as an error. Instead, they are replaced by the Unicode replacement character U+FFFD.
I kinda think this is what is going on. I just can't see the answer as my experience with go is minimal and I'm tired.
\u003Cshould be<since go always assumes utf-8.json.RawMessagethere? If a json encoder encoded message, presumably you want a json decoder to decode it.json.RawMessagehasn't been unmarshaled. You either need to unmarshal it into a string(example), or unescape the unicode yourself.