47 lines
811 B
Go
47 lines
811 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
|
|
type Server struct {
|
|
AppID int `json:"AppID"`
|
|
Name string `json:"Name"`
|
|
Map string `json:"Map"`
|
|
Players int `json:"Players"`
|
|
MaxPlayers int `json:"MaxPlayers"`
|
|
}
|
|
|
|
func main() {
|
|
serverJSON := `{
|
|
"Protocol": 17,
|
|
"Name": "Spenny.TF | DM #1",
|
|
"Map": "cp_process_final",
|
|
"Folder": "tf",
|
|
"Game": "TFTrue deathmatch ",
|
|
"AppID": 440,
|
|
"Players": 0,
|
|
"MaxPlayers": 8,
|
|
"Bots": 0,
|
|
"ServerType": 1,
|
|
"ServerOS": 1,
|
|
"Visibility": false,
|
|
"VAC": true,
|
|
"Version": "6774624",
|
|
"EDF": 177,
|
|
"ExtendedServerInfo": {
|
|
"Port": 27015,
|
|
"SteamID": 90151367621494793,
|
|
"Keywords": "cp,nocrits",
|
|
"GameID": 440
|
|
}
|
|
}`
|
|
|
|
var server Server
|
|
json.Unmarshal([]byte(serverJSON), &server)
|
|
fmt.Println(server)
|
|
}
|
|
|