I'm using the spotify web api to get a json object containing album information.
Here is the model url
https://api.spotify.com/v1/search?q=album:arrival%20artist:abba&type=album
So let's say I'm looking for the album "Nevermind" by "Nirvana" and I have this url
https://api.spotify.com/v1/search?q=album:nevermind%20artist:nirvana&type=album
So I've made a "model object" for Gson here
public class SpotifyAlbumInfo {
public CollectionInfo collectionInfo;
public class CollectionInfo {
String href;
List<Album> albums;
Integer limit;
String next;
Integer offset;
String previous;
Integer total6;
public class Album{
String album_type;
String[] available_markets;
Urls external_urls;
String href;
String id;
List<Image> images;
String name;
String type;
String uri;
public class Urls{
String source;
}
public class Image {
Integer height;
String url;
Integer width;
}
}
}
}
And here I'm trying to get the first image url
for(int i=0;i<response.collectionInfo.albums.images.size();i++){
if(response.collectionInfo.albums.image.get(i).contains("nevermind")){
imageUrl = response.collectionInfo.albums.images.get(i).url;
break;
}
}
The problem is that this statement is fine
response.collectionInfo.albums.size();
But I can't use
response.collectionInfo.albums.images.size();
Because I get the error symbol does not exist
.
I get the same error for these statements.
response.collectionInfo.albums.images.size();
response.collectionInfo.albums.album_type.size();
response.collectionInfo.albums.href.size();
// etc
How do I go "a layer deeper" into my "model object" and get the image url I want?