0

我正在尝试解析 youtube 视频提要,并为每个视频打印其缩略图列表。我试过这样的事情:

 public static class VideoFeed {
    @Key List<Video> items;
  }

  public static class 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;

  }

并打印出来

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);
  }

}

但是缩略图不会被打印出来。

有什么问题?

4

1 回答 1

1

是因为您缺少 Thumbnail.items 上的 @Key 注释吗?

于 2010-12-01T03:37:50.100 回答