我有以下有效的代码
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,
})
但是,我发现字段的重复很糟糕json,可以将其从中删除expected吗?如果我删除它会返回错误
鸿蒙传说
相关分类