I am trying to decode a map[string]interface{}
to a struct, but the "hours" field is not getting populated. I am using https://github.com/mitchellh/mapstructure for decoding. This is the struct:
BusinessAddRequest struct {
Name string `json:"name"`
Phone string `json:"phone"`
Website string `json:"website,omitempty"`
Street string `json:"street"`
City string `json:"city"`
PostalCode string `json:"postalCode"`
State string `json:"state"`
Hours []struct {
Day string `json:"day"`
OpenTimeSessionOne string `json:"open_time_session_one,omitempty"`
CloseTimeSessionOne string `json:"close_time_session_one,omitempty"`
OpenTimeSessionTwo string `json:"open_time_session_two,omitempty"`
CloseTimeSessionTwo string `json:"close_time_session_two,omitempty"`
} `json:"hours"`
Cuisine []string `json:"cuisine,omitempty"`
BusinessID int `json:"businessId,omitempty"`
AddressID int `json:"addressId,omitempty"`
UserID int `json:"userId,omitempty"`
}
And this is the example data:
{
"name": "Agave ...",
"phone": "(408) 000-000",
"street": "Abcd",
"city": "San",
"postalCode": "90000",
"state": "CA",
"hours": [
{
"day": "monday",
"open_time_session_one": "10:00",
"close_time_session_one": "21:00"
}
],
"cuisine": [
"Mexican, tacos, drinks"
],
"userId": 1
}
All fields are getting populated except "hours".