• With issues:
  • Use the search tool before opening a new issue.
  • Please provide source code and commit sha if you found a bug.
  • Review existing issues and provide feedback or react to them.

Description

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.String(200, "Hello %s", c.Param("name"))
    })
    g.Run(":9000")
}

Expectations

$ curl http://localhost:8201/hello/world
Hello world

Actual result

$ curl -i http://localhost:8201/hello/world
<YOUR RESULT>

Environment

  • go version:
  • gin version (or commit ref):
  • operating system:

my requset body

{
"product_id":1,
"product_id":2,
"product_id":3,
"product_id":4,
"product_id":5,
"product_id":6
}

how to get product_id list?

Comment From: 0x2d3c

jsonBody := `{"product_ids":[1,2,3,4,5,6]}`

var data struct {
   ProductIDs []int `json:"product_ids"`
}
ctx.Bind(&data)
ctx.BindJSON(&data)
ctx.ShouldBindJSON(&data)

which method should be choose, read method desc please

Comment From: flexmeKim

``go jsonBody :=`

var data struct { ProductIDs []int json:"product_ids" } ctx.Bind(&data) ctx.BindJSON(&data) ctx.ShouldBindJSON(&data) ```

which method should be choose, read method desc please

thank you!!