Hi
I’m trying to write a simple rest microservice in my code I have a struct like this:
type User struct {
Name string `json:"name" xml:"name" form:"name" query:"name"`
Email string `json:"email" xml:"email" form:"email" query:"email"`
Tags []string `json:"tags" xml:"tags" form:"tags" query:"tags"`
}
I can easily fetch Name and Email but for Tags Binding doesn’t work, indeed it parses an array in a wrong way, I use Bind like this:
u := new(User)
if err := c.Bind(u); err != nil {
return err
}
and the output for tags when I send a JSON array is like:
{
"name": "reza",
"email": "[email protected]",
"tags": [
"[aa1 , aa2 ]"
]
}
(rendering the whole array as one string and places it in an array)
However for tags I want it to be like:
tags:[aa1,aa2]
I would be pleased if you let me know how I can parse JSON arrays.