add json ASCII string render (#1358)

add a json render that rendering json as ASCII string
This commit is contained in:
Rex Lee(李俊)
2018-07-03 17:17:08 +08:00
committed by Bo-Yi Wu
parent d17a12591f
commit 85221af84c
5 changed files with 101 additions and 0 deletions

View File

@ -704,6 +704,12 @@ func (c *Context) JSON(code int, obj interface{}) {
c.Render(code, render.JSON{Data: obj})
}
// AsciiJSON serializes the given struct as JSON into the response body with unicode to ASCII string.
// It also sets the Content-Type as "application/json".
func (c *Context) AsciiJSON(code int, obj interface{}) {
c.Render(code, render.AsciiJSON{Data: obj})
}
// XML serializes the given struct as XML into the response body.
// It also sets the Content-Type as "application/xml".
func (c *Context) XML(code int, obj interface{}) {