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 に答える