Reduce convert between int32 and string in the AsciiJSON.Render function

This commit is contained in:
mstmdev 2022-03-24 17:31:00 +08:00
parent 5393fa858a
commit cfb4a981ff
1 changed files with 3 additions and 3 deletions

View File

@ -150,11 +150,11 @@ func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
var buffer bytes.Buffer
for _, r := range bytesconv.BytesToString(ret) {
cvt := string(r)
if r >= 128 {
cvt = fmt.Sprintf("\\u%04x", int64(r))
buffer.WriteString(fmt.Sprintf("\\u%04x", r))
} else {
buffer.WriteByte(byte(r))
}
buffer.WriteString(cvt)
}
_, err = w.Write(buffer.Bytes())