Description

When returning json data, "&" will be automatically escaped. This is an unexpected behavior, how to prohibit it?

How to reproduce

package main

import (
    "github.com/gin-gonic/gin"
)

func main() {
    g := gin.Default()
    g.GET("/hello/:name", func(c *gin.Context) {
        c.JSON(200, gin.H{
            "url": "https://godoc.org/github.com/gin-gonic/gin?a=bbb&c=333",
            })
    })
    g.Run(":9000")
}

Expectations

$ curl http://localhost:8201/hello/world
{"url":"https://godoc.org/github.com/gin-gonic/gin?a=bbb\u0026c=333"}

Actual result

$ curl -i http://localhost:8201/hello/world
{"url":"https://godoc.org/github.com/gin-gonic/gin?a=bbb&c=333"}

Environment

  • go version: go version go1.14.1 darwin/amd64
  • gin version (or commit ref): v1.6.3
  • operating system: macos

Comment From: SeanTolstoyevski

what's solution?