Is Map as query parameter supported? And if it is how to use it? I tried with:
localhost:8080?test[asd]=asd&test[dsa]=dsa
and the code
queries := c.Request.URL.Query()
// Doesn't work
log.Println(queries["test"])
// Gets the variable but not how I want it.
log.Println(queries["test[asd]"][0])
You can try this
context.GetQueryArray("test")
Was just about to post an issue regarding this subject
@picone GetQueryArray returns an array where @guzmo request is for a map, e.g -
a[]=1&a[]=2&a[]=3
Would fit for GetQueryArray
but
a[foo]=1&a[bar]=2
Would need a map as the result is the following map -
map[string]int{
"foo": 1,
"bar":2,
}
I couldn't find an existing solution for this in Gin
Any one know this solution?
I also have this problem on Post Form
@guzmo please see #1383 thanks!
Please try the latest version and see the document https://github.com/gin-gonic/gin#map-as-querystring-or-postform-parameters
Most helpful comment
Was just about to post an issue regarding this subject
@picone GetQueryArray returns an array where @guzmo request is for a map, e.g -
Would fit for GetQueryArray
but
Would need a map as the result is the following map -
I couldn't find an existing solution for this in Gin