當(dāng)我解組 json 數(shù)組時(shí)出現(xiàn)問題。我該如何糾正?代碼是: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))}
如何解組 json 數(shù)組?
慕碼人8056858
2021-07-30 17:05:01