Update README.md (#1509)

change  `ShouldBindXML` to `ShouldBindJSON`
This commit is contained in:
llgoer 2018-08-30 14:29:26 +08:00 committed by 田欧
parent 09d342abbc
commit 708b76adf0
1 changed files with 1 additions and 1 deletions

View File

@ -557,7 +557,7 @@ func main() {
// Example for binding JSON ({"user": "manu", "password": "123"}) // Example for binding JSON ({"user": "manu", "password": "123"})
router.POST("/loginJSON", func(c *gin.Context) { router.POST("/loginJSON", func(c *gin.Context) {
var json Login var json Login
if err := c.ShouldBindXML(&json); err != nil { if err := c.ShouldBindJSON(&json); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return return
} }