```
type slisli struct {
a float64 `json:"a"`
b float64 `json:"b"`
c string `json:"c"`
}
type Message struct {
Name string `json:"msg_name"`
Body string `json:"body,omitempty"` //该字段为空则忽略
Age int `json:"age"`
Sli []slisli `json:"sli"`
}
func main(){
var me Message
var me2 Messag
e
ssll1:=slisli{0.5,0.5,"aaaa"}
ssll2:=slisli{1.1,1.1,"bbbb"}
ssll3:=slisli{6.6,6.6,"cccc"}
ssll4:=slisli{7.7,7.7,"dddd"}
var sll=[]slisli{ssll1,ssll2}
me = Message{
Name: "aaa",
Body: "",
Age:12,
Sli: sll,
}
d, Rrr := json.Marshal(me)
Rrr =json.Unmarshal(d,&me2)
fmt.Println(me2)
}
```
为什么打印结果是{aaa 12 [{0 0 } {0 0 }]} ???
有疑问加站长微信联系(非本文作者)