From 535afb769b243da84730941cb57fa72b9960d7bc Mon Sep 17 00:00:00 2001 From: lijianbin <513837235@.qq.com> Date: Fri, 10 Feb 2023 14:09:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=A0=81=E8=B7=AF?= =?UTF-8?q?=E5=BE=84&=E5=AD=97=E7=AC=A6=E8=A2=AB=E8=BD=AC=E4=B9=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qrcode.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/qrcode.go b/qrcode.go index 4c8896a..314bdbb 100644 --- a/qrcode.go +++ b/qrcode.go @@ -1,6 +1,7 @@ package wechat import ( + "bytes" "encoding/base64" "errors" "fmt" @@ -49,13 +50,19 @@ func GetMiniappQrcode(access_token string, qrcodeParamsMap map[string]interface{ "auto_color": autoColor, "is_hyaline": isHyaline, } - requestDataJson, err := json.Marshal(requestData) + // json.marshal 会转义&字符 + /*requestDataJson, err := json.Marshal(requestData) if err != nil { return "", err - } + }*/ + + bf := bytes.NewBuffer([]byte{}) + jsonEncoder := json.NewEncoder(bf) + jsonEncoder.SetEscapeHTML(false) + jsonEncoder.Encode(requestData) - response, err := PostJson(getCodeUrl, requestDataJson) + response, err := PostJson(getCodeUrl, bf.Bytes()) if err != nil { return "", err