Marshaling JSON []byte as strings in Go
<p>I have a struct containing strings as []byte fields which I'd like to encode into JSON. However, the generated JSON contains a non expected string representation of the slice contents. Here is an example of what I refer:</p>

<pre><code>package main

import (
    "fmt"
    "encoding/json"
    )

type Msg struct {
    Content []byte
}

func main() {
    helloStr := "Hello"
    helloSlc := []byte(helloStr)
    fmt.Println(helloStr, helloSlc)

    obj := Msg{helloSlc}
    json, _ := json.Marshal(obj)
    fmt.Println(string(json))
}
</code></pre>

<p>This produces the following output:</p>

<pre><code>Hello [72 101 108 108 111]
{"Content":"SGVsbG8="}
</code></pre>

<p>What kind of conversion is the <a href="https://golang.org/pkg/encoding/json/#Marshal" rel="noreferrer">json.Marshal()</a> method performing to the []byte encoded string. How can I generate a JSON with the original content of my string {"Content":"Hello"}?</p>