I have a simple object defined:
type Link struct {
Href string `json:"href"`
Title string `json:"href,omitempty"`
}
type Foo struct {
Links map[string]Link `json:"_links"`
}
foo := new(Foo)
foo.Links = make(map[string]Link, 0)
foo.Links["self"] = Link{Href: "/href"}
After marshalling it to JSON, I'd expect:
{
"_links": {
"self": {
"href": "/href"
}
}
}
But instead I get:
{
"_links": {
"self": {}
}
}
Any idea why? Here's a full example: