package main
import (
"encoding/json"
"fmt"
)
type Server struct {
ServerName string
ServerIP string
}
type Serverslice struct {
Servers []Server
total string
}
func main() {
var s Serverslice
str := `{"total":"10", "servers":[{"serverName":"Shanghai_VPN","serverIP":"127.0.0.1"},{"serverName":"Beijing_VPN","serverIP":"127.0.0.2"}]}`
json.Unmarshal([]byte(str), &s)
fmt.Println(s)
}
run result:
{[{Shanghai_VPN 127.0.0.1} {Beijing_VPN 127.0.0.2}] }
Why not display total. Is there something wrong?