I have the following JSON
{"student_number":1234567, "name":"John Doe", "subjects":"Chemistry-Maths-History-Geography"}
I would like to unmarshal it in a struct, where one item (the subjects) are split on '-' into a []string.
type Student struct {
StudentNumber int `json:"student_number"`
Name string `json:"name"`
Subjects []string
}
I have attempted several different ways of achieving this with custom Unmarshalling using strings.Split(), but have not succeeded so far.
Is there any way to achieve this in the unmarshalling process? Or will I need to simply unmarshal as is and make the conversion afterward?