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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

基本的json>結(jié)構(gòu)問題(使用'Go')

基本的json>結(jié)構(gòu)問題(使用'Go')

Go
一只斗牛犬 2021-04-02 10:09:04
我正在使用Twitter的api,試圖從中獲取json數(shù)據(jù)http://search.twitter.com/trends/current.json看起來像:{"as_of":1268069036,"trends":{"2010-03-08 17:23:56":[{"name":"Happy Women's Day","query":"\"Happy Women's Day\" OR \"Women's Day\""},{"name":"#MusicMonday","query":"#MusicMonday"},{"name":"#MM","query":"#MM"},{"name":"Oscars","query":"Oscars OR #oscars"},{"name":"#nooffense","query":"#nooffense"},{"name":"Hurt Locker","query":"\"Hurt Locker\""},{"name":"Justin Bieber","query":"\"Justin Bieber\""},{"name":"Cmon","query":"Cmon"},{"name":"My World 2","query":"\"My World 2\""},{"name":"Sandra Bullock","query":"\"Sandra Bullock\""}]}}我的結(jié)構(gòu)看起來像:type trend struct {   name  string   query string  }  type trends struct {   id string   arr_of_trends []trend  }  type Trending struct {   as_of  string   trends_obj trends  }然后將JSON解析為type的變量Trending。我是JSON的新手,所以我主要關(guān)心的是確保已正確設(shè)置數(shù)據(jù)結(jié)構(gòu)以保存返回的json數(shù)據(jù)。我在“ Go”中為學(xué)校項(xiàng)目寫了這個(gè)。(這不是特定任務(wù)的一部分,而只是我正在演示有關(guān)該語言的演示內(nèi)容)更新:根據(jù)PeterSO的評(píng)論,我要使用正則表達(dá)式。使用:Cur_Trends := new(Current)/* unmarshal the JSON into our structures *///find proper json time-nameaoUnixTime, _, _ := os.Time()// insert code to find and convert as_of Unix time to aoUnixTime    aoName := time.SecondsToUTC(aoUnixTime).Format(`"2006-01-02"`)    fmt.Printf("%s\n", aoName)    regexp_pattern := "/" + aoName + "/"    regex, _ := regexp.Compile(regexp_pattern);    cleaned_json := regex.ReplaceAllString(string(body2), "ntrends")    os.Stdout.WriteString(cleaned_json)不顯示任何更改。我指定的regexp錯(cuò)誤嗎?看起來“開始”一次只允許一個(gè)正則表達(dá)式...更新:現(xiàn)在可以將日期/時(shí)間更改為“ ntrends”,但“取消編組”無效。我可以使用json.Decode將所有內(nèi)容移入接口,但無法對(duì)其進(jìn)行迭代...使用“ for ... range”給我奇怪的東西...
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 306 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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