msgpack
msgpack copied to clipboard
struct flat
var structA struct {
ID int `json:"id" msgpack:"id"`
}
var structB []struct {
structA
Title string `json:"title" msgpack:"title"`
}
for _, s := range structAarrs {
item := struct {
structA
Title string `json:"title" msgpack:"title"`
}{
Title: Title,
}
item.structA= s
structB = append(structB, item)
}
expect:
[
{
"id": 1,
"title": "title"
}
]
actual:
[
{
"structA": {
"id": 1
},
"title": "title"
}
]