我正在尝试从此页面打印数据:https://www.rolimons.com/api/activity
这是它的外观:
{"success":true,"activities":[[1624720645,1,6815676017,1080,1047,563399],[1624720637,1,6807138720,915,893,563398],[1624720633,1,6803395856,683,687,563397],[1624720633,1,2409285794,44853,44867,563396],[1624720623,1,71484026,2172,2114,563395],[1624720613,1,9254254,6620,6632,563394],[1624720611,1,124472052,1054,1048,563393],[1624720581,1,6803403781,671,653,563392],[1624720578,1,44113968,972,980,563391],[1624720527,1,332772333,2274,2264,563390]],"activities_count":10}
我用 https://mholt.github.io/json-to-go/ 得到:
type data struct {
Success bool `json:"success"`
Activities [][]interface{} `json:"activities"`
ActivitiesCount int `json:"activities_count"`
}
这是我的代码:
resp, err := http.Get("https://www.rolimons.com/api/activity")
if err != nil {
panic(err)
}
defer resp.Body.Close()
var data *data
error := json.NewDecoder(resp.Body).Decode(&data)
if error != nil {
panic(error)
}
println(data.Activities)
但它给了我这个:
[11/13]0xc0002bc000
但我想让它打印第4和第5个值,例如:
{"success":true,"activities":[[1624720645,1,6815676017,1080,1047,563399]
将:
1080,1047
喵喵时光机
相关分类