There is a problem with golang parsing json.

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?

Mar.22,2021

total is lowercase and cannot be exported. Read more documents

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8f673-1251.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8f673-1251.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?