I have two structs struct:
type A struct {
Zip string `json:"zip"`
}
type B struct {
Foo string `bson:"foo"`
Bar A `json:"bar"`
}
When I try to json.Marshal
the B
type, the Bar
field does not get converted correctly. The fields are OK, but the values are always empty. The output looks like this:
{"foo": "some-string-value", "bar": {"zip": ""}}
What am I doing wrong?