当我解组 json 数组时出现问题。我该如何纠正?代码是:http : //play.golang.org/p/AtU9q8Hlyepackage mainimport ( "encoding/json" "fmt")type Server struct { ServerName string ServerIP string}type Serverslice struct { Name string Servers []Server}func main() { var s []Serverslice str := `{"name":"dxh","servers":[{"serverName":"VPN0","serverIP":"127.0.0.1"},{"serverName":"Beijing_VPN","serverIP":"127.0.0.2"}], "name":"dxh1,"servers":[{"serverName":"VPN1","serverIP":"127.0.0.1"},{"serverName":"Beijing_VPN","serverIP":"127.0.0.2"}]}` json.Unmarshal([]byte(str), &s) //the wrong line..................... fmt.Println(len(s))}
1 回答
- 1 回答
- 0 关注
- 161 浏览
添加回答
举报
0/150
提交
取消