mirror of
https://github.com/gin-gonic/gin.git
synced 2026-11-23 11:33:37 +08:00
Merge branch 'master' into fix/form-binding-jsoniter
This commit is contained in:
commit
662584d4d9
@ -1236,7 +1236,7 @@ func (c *Context) IndentedJSON(code int, obj any) {
|
||||
}
|
||||
|
||||
// SecureJSON serializes the given struct as Secure JSON into the response body.
|
||||
// Default prepends "while(1)," to response body if the given struct is array values.
|
||||
// Default prepends "while(1);" to response body if the given struct is array values.
|
||||
// It also sets the Content-Type as "application/json".
|
||||
func (c *Context) SecureJSON(code int, obj any) {
|
||||
c.Render(code, render.SecureJSON{Prefix: c.engine.secureJSONPrefix, Data: obj})
|
||||
|
||||
@ -1167,7 +1167,7 @@ func main() {
|
||||
|
||||
```sh
|
||||
curl -X POST http://localhost:8080/person
|
||||
{"Name":"William","Age":10,"Friends":["Will","Bill"],"Colors":["red","blue"],"LapTimes":[1,2,3]}
|
||||
{"Name":"William","Age":10,"Friends":["Will","Bill"],"Addresses":["foo","bar"],"LapTimes":[1,2,3]}
|
||||
```
|
||||
|
||||
NOTE: For default [collection values](#collection-format-for-arrays), the following rules apply:
|
||||
@ -1762,7 +1762,7 @@ func main() {
|
||||
|
||||
#### SecureJSON
|
||||
|
||||
Using SecureJSON to prevent json hijacking. Default prepends `"while(1),"` to response body if the given struct is array values.
|
||||
Using SecureJSON to prevent json hijacking. Default prepends `"while(1);"` to response body if the given struct is array values.
|
||||
|
||||
```go
|
||||
func main() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user