如何打印 JSON?當我打印時,我一直在獲取數組中的隨機數,有沒有辦法打印 JSON 而不是解析它?這是 main.go 中的函數 func sendpostget(word string) {// Create a new spotify objectspot := spotify.New("number", "number")// Authorize against Spotify firstauthorized, _ := spot.Authorize()if authorized { // If we ere able to authorize then Get a simple album // s := join("artists/", phone) s := "artists/xxxx/albums?market=ES&limit=2" fmt.Println(s) response, _ := spot.Get(s, nil) fmt.Println(response)}// Parse response to a JSON Object and }這是我正在使用的結構(此 get 方法將從 spotify API 檢索藝術家的專輯)type Albums struct { Albums []Album `json:"users"`} type Album struct { AlbumType string `json:"album_type"` Href string `json:"href"` ID string `json:"id"`}
1 回答

阿晨1998
TA貢獻2037條經驗 獲得超6個贊
如果您正在獲取大量數字作為 JSON 正文而不是文本,那么它可能是字節數組而不是字符串。要解決此問題,請轉換為字符串
response, _ := spot.Get(s, nil) fmt.Println(string(response))
- 1 回答
- 0 關注
- 143 瀏覽
添加回答
舉報
0/150
提交
取消