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)
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-1b3c101-2c2e9.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-1b3c101-2c2e9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?