mirror of https://github.com/gin-gonic/gin.git
Reduce convert between int32 and string in the AsciiJSON.Render function
This commit is contained in:
parent
5393fa858a
commit
cfb4a981ff
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue