From 7c4b8fe1724cbd3866e87479d5af7a5ec9c41082 Mon Sep 17 00:00:00 2001 From: silenceper Date: Mon, 13 Feb 2017 00:25:14 +0800 Subject: [PATCH] =?UTF-8?q?json=20marshal=E6=94=B9=E4=B8=BAencode=20?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E8=BD=AC=E4=B9=89html=E5=AD=97=E7=AC=A6(?= =?UTF-8?q?=E4=BE=8B=E5=A6=82=EF=BC=9A&)=20#15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/http.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/util/http.go b/util/http.go index 05f9d29..151a41d 100644 --- a/util/http.go +++ b/util/http.go @@ -27,12 +27,16 @@ func HTTPGet(uri string) ([]byte, error) { //PostJSON post json 数据请求 func PostJSON(uri string, obj interface{}) ([]byte, error) { - jsonData, err := json.Marshal(obj) + jsonBuf := new(bytes.Buffer) + enc := json.NewEncoder(jsonBuf) + enc.SetEscapeHTML(false) + err := enc.Encode(obj) + if err != nil { return nil, err } - body := bytes.NewBuffer(jsonData) - response, err := http.Post(uri, "application/json;charset=utf-8", body) + + response, err := http.Post(uri, "application/json;charset=utf-8", jsonBuf) if err != nil { return nil, err }