Help with google-api-java-client
I'm trying to parse a youtube video feed, and for each video print the list of its thumbnails. I've tried something like that:
public static class VideoFeed {
@Key List<Video> items;
}
public static clas开发者_运维百科s Video {
@Key String title;
@Key String description;
@Key DateTime uploaded;
@Key Player player;
@Key Thumbnail thumbnail;
}
public static class Player {
@Key("default") String defaultUrl;
}
public static class Thumbnail{
List<Thumb> items = new ArrayList<Thumb>();
}
public static class Thumb extends GenericJson{
@Key("default") String defaultUrl;
@Key Integer height;
@Key Integer width;
@Key String time;
}
and print it
for (Video video : feed.items) {
System.out.println();
System.out.println("Video title: " + video.title);
System.out.println("Uploaded: " + video.uploaded);
System.out.println("URL: " + video.player.defaultUrl);
Thumbnail thumbnails = video.thumbnail;
for (Thumb thumb : thumbnails.items){
System.out.println("Thumbnail: "+thumb.defaultUrl);
}
}
But the thumbnails don't get printed.
What's the problem?
Is it because you are missing the @Key annotation on the Thumbnail.items?
精彩评论