给定以下结构类型,StructA并且StructB嵌入在CompleteStruct
type StructA struct {
A int `json:"a_a"`
B int `json:"a_b"`
C int `json:"a_c"`
}
type StructB struct {
A int `json:"b_a"`
B int `json:"b_b"`
}
type CompleteStruct struct {
Name string `json:"name"`
StructA
StructB
}
Run Code Online (Sandbox Code Playgroud)
这s是一个新的结构。
s := CompleteStruct{Name: "Example",
StructA: StructA{
A: 1,
B: 2,
C: 3,
},
StructB: StructB{
A: 4,
B: 5,
},
}
Run Code Online (Sandbox Code Playgroud)
如何转化s为下面的json.
type StructA struct {
A int `json:"a_a"`
B int `json:"a_b"`
C int …Run Code Online (Sandbox Code Playgroud)