Suppose I define a struct as following:
type User struct {
ID string
Name string
Age uint
City string `json:"address.city"`
Province string `json:"address.province"`
}
I am able to take a User struct, and expand out the flattened fiends into a nested JSON structure, with an address object. I'm struggling however to go in the other direction.
How would I take the following JSON:
{
"ID": "1",
"Name": "Keith Baldwin",
"Age": 30,
"address": {
"city": "Saskatoon",
"province": "Saskatchewan"
}
}
And unmarshal it into the given struct?
Is there something I'm missing, or will I just have to write it from scratch, probably using reflection?
Thanks