The result parsed by json.Unmarshal is empty.

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)
}

print out the results, total and count are empty, what"s going on.

Mar.22,2021

    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)
Menu