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

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

無法將 json 數(shù)據(jù)解組為 go 中的結(jié)構(gòu)(無法將數(shù)組解組為 Go 結(jié)構(gòu)字段)

無法將 json 數(shù)據(jù)解組為 go 中的結(jié)構(gòu)(無法將數(shù)組解組為 Go 結(jié)構(gòu)字段)

Go
青春有我 2022-04-25 17:23:25
我正在使用 API 接收來自某個組織的所有招聘廣告,我收到的 JSON 數(shù)據(jù)非常大,我想在 Go 中使用這些數(shù)據(jù),但是我在解組到結(jié)構(gòu)時遇到了問題,因此我可以進一步使用它。這可能是一個非常簡單的解決方案,對我來說是盲目的,因為我這個問題引起了一些頭痛。代碼中的 API 密鑰是公開的,因此與 Stackoverflow 共享它沒有問題。代碼:package mainimport (    "encoding/json"    "fmt"    "io/ioutil"    "log"    "net/http")type JsonData struct {    Content JsonContent `json:"content"`    TotalElements int `json:"totalElements"`    PageNumber int `json:"pageNumber"`    PageSize int `json:"pageSize"`    TotalPages int `json:"totalPages"`    First bool `json:"first"`    Last bool `json:"last"`    Sort string `json:"sort"`}type JsonContent struct {    Uuid string `json:"uuid"`    Published string `json:"published"`    Expires string `json:"expires"`    Updated string `json:"updated"`    WorkLoc WorkLocations `json:"workLocations"`    Title string `json:"title"`    Description string `json:"description"`    SourceUrl string `json:"sourceurl"`    Source string `json:"source"`    ApplicationDue string `json:"applicationDue"`    OccupationCat OccupationCategories `json:"occupationCategories"`    JobTitle string `json:"jobtitle"`    Link string `json:"link"`    Employ Employer `json:"employer"`    EngagementType string `json:"engagementtype"`    Extent string `json:"extent"`    StartTime string `json:"starttime"`    PositionCount interface{} `json:"positioncount"`    Sector string `json:"sector"`}type WorkLocations struct {    Country string `json:"country"`    Address string `json:"address"`    City string `json:"city"`    PostalCode string `json:"postalCode"`    County string `json:"county"`    Municipal string `json:"municipal"`}type OccupationCategories struct {    Level1 string `json:"level1"`    Level2 string `json:"level2"`}type Employer struct {    Name string `json:"name"`    Orgnr string `json:"orgnr"`    Description string `json:"description"`    Homepage interface{} `json:"homepage"`}
查看完整描述

1 回答

?
忽然笑

TA貢獻1806條經(jīng)驗 獲得超5個贊

解決方案已經(jīng)被“zerkms”、“tclass”這兩個可愛的人找到了。

您聲稱 Content JsonContentjson:"content"是 JsonContent,而它是它們的數(shù)組,因此 []JsonContent

正如您在示例 json 中看到的,內(nèi)容字段實際上是一個數(shù)組。在你的 go 結(jié)構(gòu)中它不是。您必須將結(jié)構(gòu)更改為 Content []JsonContent json:"content"

非常感謝你們!


查看完整回答
反對 回復(fù) 2022-04-25
  • 1 回答
  • 0 關(guān)注
  • 204 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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