I have some sample json like this:
"payment_details": {
"acc_number": "",
"sort_code_1": "00",
"sort_code_2": "11",
"sort_code_3": "22"
},
which I am unmarshaling like so
i := &MyStruct{}
return i, json.Unmarshal(theJson, &i)
and I want MyStruct to look like this
type MyStruct struct {
AccNumber *string `json:"acc_number"`
SortCode *string `json:"sort_code"`
}
However I'd like to combine the separate sort code fields into one, so that in the end MyStruct will look like this
type MyStruct struct {
AccNumber *string `json:"acc_number"`
SortCode *string `json:"sort_code"` // "00-11-22"
}
Is there a clever way to do this while unmarshaling?