Go json parsing problem, help us.

json is parsed as nil, and individual data is fetched from a nested json operation.

this is json data:

{
    "code": 0,
    "data": {
        "song": {
            "count": 2,
            "itemlist": [{
                "albummid": "001ZaCQY2OxVMg",
                "docid": "4960718353595419009",
                "id": "108041208",
                "mid": "000lH7Do3X6Aot",
                "name": "",
                "singer": ""
            }, {
                "albummid": "001ZaCQY2OxVMg",
                "docid": "4277524965976373789",
                "id": "107195477",
                "mid": "0004snbm3ZMeFz",
                "name": "",
                "singer": ""
            }],
            "name": "",
            "order": 0,
            "type": 1
        }
    },
    "subcode": 0
}

I have tried to take out the transformants for nil
, and I have also tried to convert various types, which is also nil

.

find a solution, how to get

Mar.21,2021

has been resolved! Complain: audit is slow
nested structures:

type SongSingle struct {
    Codes int `json:"code"`
    Date  struct {
        Song struct { // 
            Count    int `json:"count"`
            Itemlist []struct {
                Albummid string `json:"albummid"`
                Docid    string `json:"docid"`
                Id       string `json:"id"`
                Mid      string `json:"mid"`
                Name     string `json:"name"`
                Singer   string `json:"singer"`
            } `json:"itemlist"`
            Name  string `json:"name"`
            Order int    `json:"order"`
            Type  int    `json:"type"`
        } `json:"song"`
        Album struct { // 
            Count    int `json:"count"`
            Itemlist []struct {
                docid  string `json:"docid"`
                Id     string `json:"id"`
                Mid    string `json:"mid"`
                Name   string `json:"name"`
                Pic    string `json:"pic"`
                Singer string `json:"singer"`
            } `json:"itemlist"`
            Name  string `json:"name"`
            Order int    `json:"order"`
            Type  int    `json:"type"`
        } `json:"album"`
        Singer struct { // 
            Count    int `json:"count"`
            Itemlist []struct {
                docid  string `json:"docid"`
                Id     string `json:"id"`
                Mid    string `json:"mid"`
                Name   string `json:"name"`
                Pic    string `json:"pic"`
                Singer string `json:"singer"`
            } `json:"itemlist"`
            Name  string `json:"name"`
            Order int    `json:"order"`
            Type  int    `json:"type"`
        } `json:"singer"`
        Mv struct { // mv
            Count    int `json:"count"`
            Itemlist []struct {
                docid  string `json:"docid"`
                Id     string `json:"id"`
                Mid    string `json:"mid"`
                Name   string `json:"name"`
                Singer string `json:"singer"`
                Vid    string `json:"vid"`
            } `json:"itemlist"`
            Name  string `json:"name"`
            Order int    `json:"order"`
            Type  int    `json:"type"`
        } `json:"mv"`
        Name  string `json:"name"`
        Order int    `json:"order"`
        Type  int    `json:"type"`
    } `json:"data"`
    Subcode int `json:"subcode"`
}

traversal structure body value:

Sbody: = string (body)
var arrayData SongSingle
if err: = json.Unmarshal ([] byte (Sbody), & arrayData); err = = nil {

// fmt.Println(":", arrayData.Subcode)
// fmt.Println(":", arrayData.Subcode)
for _, Songitem := range arrayData.Date.Song.Itemlist {
    fmt.Println("ID:", Songitem.Albummid)
    fmt.Println("  ID  :", Songitem.Id)
    fmt.Println("ID:", Songitem.Mid)
    fmt.Println("  :", Songitem.Name)
    fmt.Println("  :", Songitem.Singer)
    fmt.Println("\n")
}

} else {

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