I have the following code that works
type Q struct {
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
CreatedAt time.Time `json:"created_at"`
ID uuid.UUID `json:"id"`
Name string `json:"name"`
UpdatedAt time.Time `json:"updated_at"`
}
expected, _ := json.Marshal(Q{Links: struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
}{
Self: struct {
Href string `json:"href"`
}{
Href: url,
},
},
ID: id,
Name: name,
CreatedAt: now,
UpdatedAt: now,
})
However, I find bad the repeteation of json
fields, it is possible to remove it from expected
? If I remove it returns an error