AsciiJSON

Using AsciiJSON to Generates ASCII-only JSON with escaped non-ASCII characters.

  1. func main() {
  2. r := gin.Default()
  3. r.GET("/someJSON", func(c *gin.Context) {
  4. data := map[string]interface{}{
  5. "lang": "GO语言",
  6. "tag": "<br>",
  7. }
  8. // will output : {"lang":"GO\u8bed\u8a00","tag":"\u003cbr\u003e"}
  9. c.AsciiJSON(http.StatusOK, data)
  10. })
  11. // Listen and serve on 0.0.0.0:8080
  12. r.Run(":8080")
  13. }

Last modified June 22, 2020 : Fix Small Typo (#135) (75a17c1)