在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/GO/ json.Unmarshal 解析出來(lái)結(jié)果為空

json.Unmarshal 解析出來(lái)結(jié)果為空

package main

import (
"encoding/json"
"fmt"
)

type Serverslice2 struct {
    total string
    count string
    start string
}

func main() {
    var s Serverslice2
    str := `{"count": 10,"start": 0,"total": 1626}`
    json.Unmarshal([]byte(str), &s)
    fmt.Println(s.total + " abc " + s.count)
}

打印出來(lái)結(jié)果,total和count都為空,怎么回事。

回答
編輯回答
離夢(mèng)
    type Serverslice2 struct {
        Total int `json:"total"`
        Count int `json:"count"`
        Start int `json:"start"`
    }

    var s Serverslice2
    str := `{"count": 10,"start": 0,"total": 1626}`
    err := json.Unmarshal([]byte(str), &s)
    fmt.Println(s, err)
2017年1月21日 01:33