I have a struct of called class like this.
type ClassDetails struct {
ClassNumber int `json:"classNumber"`
Names []string `json:names`}
I have manually created something like this.
type Subject struct {
Math ClassDetails `json:"math"`
Science ClassDetails `json:"science"`}
I want to do this on the fly. Add more ClassDetails to the Subject as I get information, but I cannot use an array of type class. How can this be done? And I also need to add the names of the classes as the json tag. My resultant struct should hold values like this.
{
"classes": {
"school": "MayorWestHigh",
"math": [{
"classNumber": "1",
"names": ["aaron", "baron", "cathy"]
},
{
"classNumber": "2",
"names": ["aaron", "baron", "cathy"]
}
],
"science": [{
"classNumber": "1",
"names": ["ted", "baron", "isiah"]
}],
"geography": [{
"classNumber": "1",
"names": ["peter", "glen", "joe"]
}]
}
}