How do I marshal a nested struct into JSON? I know how to marshal the struct without any nested structs. However when I try to make the JSON response look like this:

{"genre": {"country": "taylor swift", "rock": "aimee"}}

I run into problems.

My code looks like this:

Go:

type Music struct { Genre struct { Country string Rock string } } resp := Music{ Genre: { // error on this line. Country: "Taylor Swift", Rock: "Aimee", }, } js, _ := json.Marshal(resp) w.Write(js)

However, I get the error

Missing type in composite literal

How do I resolve this?