Golang custom map is converted into a two-dimensional array json

    MapSq := make(map[int]string)
    MapZz := make(map[int]string)
    MapWf := make(map[int]string)
    MapLj := make(map[int]string)
    MapQz := make(map[int]string)
    MapQt := make(map[int]string)
    MapSq[1] = "AAAAA"
    MapZz[2] = "BBBBB"
    MapWf[3] = "CCCCC"
    MapLj[4] = "DDDDD"
    MapQz[5] = "EEEEE"
    MapQt[6] = "FFFFF"
    var list = [6]interface{}{MapSq, MapZz, MapWf, MapLj, MapQz, MapQt}
    c.AsciiJSON(http.StatusOK, map[string]interface{}{
        "data":     list,
    })
{
    "data": [
        {
            "1": "色情低俗1"
        },
        {
            "2": "色情低俗2"
        },
        {
            "3": "色情低俗3"
        },
        {
            "4": "色情低俗4"
        },
        {
            "5": "色情低俗5"
        },
        {
            "6": "色情低俗6"
        }
    ]
}

Leave a Reply

Your email address will not be published.

en_USEnglish