第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Golang Facebook對結(jié)構(gòu)的回應

Golang Facebook對結(jié)構(gòu)的回應

Go
叮當貓咪 2021-04-05 13:18:12
我是GO的新手,我想將json從facebook api轉(zhuǎn)換為struct。問題在于對象的鍵是動態(tài)的:{  "100555213756790": {    "id": "100555213756790",    "about": "Noodle Bar & Restaurant",    "metadata": {      "fields": [        {          "name": "id",          "description": "asdasdasdasd",          "type": "numeric string"        },        //...  ,  "101285033290986": {    "id": "101285033290986",    "about": "Smart City Expo World Congress",    "metadata": {      "fields": [        {          "name": "id",          "description": "fgddgdfgdg",          "type": "numeric string"        },到目前為止,我所實現(xiàn)的是通過id提取對象并將其轉(zhuǎn)換為地圖:for _, id := range ids {    fbPages, ok := results[string(id)].(map[string]interface{})    if ok {        for k, v := range fbPages {            fmt.Println(k)            fmt.Println(v)        }    }}//json to Page struct?    type Page struct {        ID                string   `json:"id"`        About             string   `json:"about"`    }    type Metadata struct {        Fields      []Field           `json:"fields"`        Type        string            `json:"type"`        Connections map[string]string `json:"connections"`    }    type Field struct {        Name        string  `json:"name"`        Description string  `json:"description"`        Type        *string `json:"type,omitempty"`    }我的問題是:如何將該映射轉(zhuǎn)換為struct?還是有什么簡單的方法可以做我想做的事情?
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 286 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號