too long

i try to put json data to web, i use json.Marshal to create json data.

Flowing picture is fmt.Println(string(jsonOut)) result

enter image description here

i use template.HTMLEscape(w, []byte(jsonOut)) to show in web, it will show like following picture.

enter image description here

the " become &#34.

why it will show &#34 and how can i do for show "?

template.HTMLEscape will escape special character.

use following code can post json data to web

w.Header().Set("Content-Type", "application/json")
w.Write(jsonOut)

reference https://www.alexedwards.net/blog/golang-response-snippets#json

If you just want show json in the http response

w.Write(jsonOut)

If you want to show json in html

t, _ := template.New("foo").Parse(`<head></head><body>{{$.data}}</body>`)   
_ = t.Execute(w, map[string]string{
    "data": string(jsonOut),
})