How to parse html form array with Beego.
Thanks @ysqi for giving me a hint. I am adding a little detailed example to parse associate array like form data in beego
Here is my form structure:
golang(beego) code:
contacts := make([]map[string]string, 0, 3)
this.Ctx.Input.Bind(&contacts, "contacts")
contacts variable:
[
{
"email": "user2@gmail.com",
"first_name": "Sam",
"last_name": "Gamge"
},
{
"email": "user3@gmail.com",
"first_name": "john",
"last_name": "doe"
}
]
Now you can use it like:
for _, contact := range contacts {
contact["email"]
contact["first_name"]
contact["last_name"]
}