I'm not sure how to create a struct
to store a JSON object that is being posted to my API.
The JSON looks like this:
{
"name" : "Mr Robinson",
"email" : "test@test.com",
"username" : "robbo123",
"properties" : {
"property1" : "a property",
"property2" : "another property"
},
"permissions" : ["perm1", "perm2", "perm3"]
}
There can be any number of properties
and the permissions
array can contain any number of values.
I am using this to decode the posted values:
err := json.NewDecoder(req.Body).Decode(my_struct)
So far my struct looks like this:
type User struct {
Name string `json:"name"`
Email string `json:"email"`
Username string `json:"username"`
}