So basically i am playing with JSON and nested JSON objects (not in the form of arrays []) using structs. I bet this is really simple but why am i struggling to create a nested JSON object 1 level deep using two struct types?
package main
import (
"encoding/json"
"fmt"
)
type MetaData struct {
Country string `json:"countryScope"`
Asset string `json:"assetScope"`
}
type BusEvent struct {
MedaData MetaData `json:"metaData"`
Name string
}
func main() {
resp := BusEvent{
MetaData{
Country: "test",
Asset: "test",
},
Name: "test",
}
js, _ := json.Marshal(resp)
fmt.Printf("%s", js)
}