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

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

如何為 json 創(chuàng)建正確的結(jié)構(gòu)

如何為 json 創(chuàng)建正確的結(jié)構(gòu)

Go
慕勒3428872 2023-03-29 15:35:34
如何正確解析 json 我有以下 json 文件{    "hello": {        "title": "Golang",        "story": [            "Go lang story",            "Channel story"        ],        "options": [            {                "text": "That story",                "arc": "west"            },            {                "text": "Gee",                "arc": "east"            }        ]    },    "world": {        "title": "Visiting",        "story": [            "Boo",            "Doo",            "Moo",            "Qoo"        ],        "options": [            {                "text": "weird",                "arc": "west"            },            {                "text": "funny",                "arc": "north"            }        ]    }}我為內(nèi)部創(chuàng)建了這些結(jié)構(gòu)type chapter struct{    Title string `json:"title"`    Story []string `json:"story"`    Option []option `json:"options"`}type option struct {    Text string `json:"text"`    Arc string `json:"arc"`}但我不知道如何解析像“hello”和“world”這樣的包裝器
查看完整描述

1 回答

?
繁花不似錦

TA貢獻(xiàn)1851條經(jīng)驗 獲得超4個贊

您需要做的就是構(gòu)建根映射。

{
????"hello":{},
????????"world":{}
}

這里的helloworld也在地圖內(nèi)。所以你也需要構(gòu)建它們。

?var?root?map[string]chapter
?json.Unmarshal(JSONDATA,&root)


查看完整回答
反對 回復(fù) 2023-03-29
  • 1 回答
  • 0 關(guān)注
  • 104 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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