正确的POJO模型

时间:2016-04-22 05:44:32

标签: android retrofit jsonschema2pojo

如何根据我的需求创建正确的POJO模型?我想处理一个Web服务器的响应。结果是https://api.vid.me/videos/featured 但它非常大,我只需要标题,喜欢的数量和视频的网址,我怎样才能正确使用Retrofit库?

1 个答案:

答案 0 :(得分:0)

仅使用Json的一小部分并将其粘贴到http://www.jsonschema2pojo.org/将为您生成Pojo。 像

{
    "status": true,
    "page": {
        "offset": 0,
        "limit": 20,
        "total": 1713,
        "currentMarker": null,
        "currentMarkerDay": null,
        "currentMarkerDate": null,
        "nextMarker": "2016-04-21"
    },
    "videos": [{
        "video_id": "8771660",
        "url": "ApfZ",
        "full_url": "https:\/\/vid.me\/ApfZ",
        "embed_url": "https:\/\/vid.me\/e\/ApfZ",
        "user_id": "6747684",
        "complete": "s3:\/\/v.vidd.me\/videos\/8771660.og2.mp4",
        "complete_url": "https:\/\/d1wst0behutosd.cloudfront.net\/videos\/8771660.og2.mp4?Expires=1461310213&Signature=PnA8PH5UES15z5Pm9mxsGAMAXglY6t5iy7f6b64IZlI0AkYvD2Y7D7hwzWnKBdHe3f8315pR6rQNKd3PBcWIoJ~lRq~MCuM740GhkKuF2B1tmNXYMIf58-MwNL0ldKbub39oRlLc7EdnhecM8MVZCZkBxcTLZNHwBJeG~ass0DHG0Xe68EmmPGvCx3~dJ6tzSZEHMFs7H3VVGNp2Ow6vbxD4cO5SO31SyYS0StivurMg40RC51b2KHQJybTsmOM5EwxhqF60EELa0mARYL46kbXJtzrXvbKaeZCpN9P9kSuqeGJzUmh1GL3bR9JZjN1cZGKHugahTOZyHs7YfRWnxA__&Key-Pair-Id=APKAJJ6WELAPEP47UKWQ",
        "state": "success",
        "title": "RIP Prince | Prince performs \u201cPurple Rain\u201d during downpour at Super Bowl XLI ",
        "description": "#prince #purplerain #music #randb #ripprince ",
        "duration": 492.08,
        "height": 360,
        "width": 640,
        "date_created": "2016-04-21 18:06:42",
        "date_stored": "2016-04-21 18:07:40",
        "date_completed": "2016-04-21 18:07:43",
        "comment_count": 11,
        "view_count": 6815,
        "share_count": 15,
        "version": 10,
        "nsfw": false,
        "thumbnail": "thumbnails\/8771660\/8771660.jpg?v2r1461269880",
        "thumbnail_url": "https:\/\/d1wst0behutosd.cloudfront.net\/thumbnails\/8771660\/8771660.jpg?v2r1461269880",
        "thumbnail_gif": "thumbnails\/8771660\/8771660.gif?v1r1461269888",
        "thumbnail_gif_url": "https:\/\/d1wst0behutosd.cloudfront.net\/thumbnails\/8771660\/8771660.gif?v1r1461269888",
        "storyboard": "https:\/\/d1wst0behutosd.cloudfront.net\/storyboards\/8771660\/8771660-{05}.jpg?v1r1461262073",
        "score": 36,
        "likes_count": 21,
        "channel_id": null,
        "source": "computer",
        "private": false,
        "latitude": 0,
        "longitude": 0,
        "place_id": null,
        "place_name": null,
        "colors": "#403742,#bf9fa2,#8a747e,#637282,#8a94a6,#706d6a",
        "reddit_link": null,
        "youtube_override_source": null,
        "watching_count": 87,
        "clip_url": "https:\/\/d1wst0behutosd.cloudfront.net\/videos\/8771660\/23259725-clip.mp4",
        "is_featured": true,
        "date_featured": "2016-04-21 20:06:31",
        "score_modifier": 15,
        "user": {
            "user_id": "6747684",
            "username": "Balle_Courbe",
            "full_url": "https:\/\/vid.me\/Balle_Courbe",
            "avatar": "avatars\/6747684.jpg?v4r1445280831",
            "avatar_url": "https:\/\/d1wst0behutosd.cloudfront.net\/avatars\/6747684.jpg?v4r1445280831",
            "cover": "channel_covers\/6747684.jpg?v1r1445280846",
            "cover_url": "https:\/\/d1wst0behutosd.cloudfront.net\/channel_covers\/6747684.jpg?v1r1445280846",
            "displayname": null,
            "follower_count": 46,
            "likes_count": "259",
            "video_count": 257,
            "video_views": "1059777",
            "videos_scores": 865,
            "comments_scores": 0,
            "bio": "Un site de sport compl\u00e8tement d\u00e9cal\u00e9 en partenariat avec RDS et Urbania\r\nwww.ballecourbe.ca"
        },
        "formats": [{
            "type": "dash",
            "uri": "https:\/\/api.vid.me\/video\/8771660\/stream?format=dash",
            "width": null,
            "height": null,
            "version": 10
        }, {
            "type": "hls",
            "uri": "https:\/\/api.vid.me\/video\/8771660\/stream?format=hls",
            "width": null,
            "height": null,
            "version": 10
        }]
    } ,{
        "video_id": "8734973",
        "url": "42fG",
        "full_url": "https:\/\/vid.me\/42fG",
        "embed_url": "https:\/\/vid.me\/e\/42fG",
        "user_id": null,
        "complete": "s3:\/\/v.vidd.me\/videos\/8734973\/23148626.480p.mp4",
        "complete_url": "https:\/\/d1wst0behutosd.cloudfront.net\/videos\/8734973\/23148626.480p.mp4?Expires=1461310213&Signature=DbCfZIeK6mEqkIz3JNCA6-3ICqSfLA6v9xGumZHORoV14CUtp2YH23V8Qd7Em8uzUWKPDvJfhRINY8KZLRUlK2N6sbaDV3aX~-onQcn9E6giLEvaSIQJIvQ6raG0x3~WO~QD85BchQoVbfBzPBqphNY3q9X3gJaxOBNV02hbxxGEXFN8vTmmnx6vk8qyAtBCHmABpDNSt1ZxqM6leHDgQGQcBxjKmY9U8OtaEJ-WTUz-PC2bz89k6b~iQRSzSi3tQcGrkiSvoueLGVNmznDbKbpb48yjKins9nk6o86NWH9IHs03k~NKUtq39u7eOcAYY3MFc84VpRM9R~146ZtBPg__&Key-Pair-Id=APKAJJ6WELAPEP47UKWQ",
        "state": "success",
        "title": "POV dirt biking ",
        "description": "#dirtbiking #motocross #sports #offroad #pov #gopro ",
        "duration": 200.27,
        "height": 480,
        "width": 854,
        "date_created": "2016-04-19 12:38:05",
        "date_stored": "2016-04-19 12:40:46",
        "date_completed": "2016-04-19 12:41:33",
        "comment_count": 9,
        "view_count": 9832,
        "share_count": 14,
        "version": 10,
        "nsfw": false,
        "thumbnail": "thumbnails\/8734973\/8734973.jpg?v2r1461103001",
        "thumbnail_url": "https:\/\/d1wst0behutosd.cloudfront.net\/thumbnails\/8734973\/8734973.jpg?v2r1461103001",
        "thumbnail_gif": "thumbnails\/8734973\/8734973.gif?v1r1461103012",
        "thumbnail_gif_url": "https:\/\/d1wst0behutosd.cloudfront.net\/thumbnails\/8734973\/8734973.gif?v1r1461103012",
        "storyboard": "https:\/\/d1wst0behutosd.cloudfront.net\/storyboards\/8734973\/8734973-{03}.jpg?v1r1461069698",
        "score": 31,
        "likes_count": 21,
        "channel_id": null,
        "source": "computer",
        "private": false,
        "latitude": 0,
        "longitude": 0,
        "place_id": null,
        "place_name": null,
        "colors": "#414047,#d0c6ca,#938c91,#a7b1b3,#a5a2ac,#797e7c",
        "reddit_link": "https:\/\/www.reddit.com\/r\/Dualsport\/comments\/4fheuc\/took_some_fellow_xr_riders_dirt_cherries\/",
        "youtube_override_source": null,
        "watching_count": 4,
        "clip_url": "https:\/\/d1wst0behutosd.cloudfront.net\/videos\/8734973\/23148629-clip.mp4",
        "is_featured": true,
        "date_featured": "2016-04-19 21:55:48",
        "score_modifier": 12,
        "formats": [{
            "type": "dash",
            "uri": "https:\/\/api.vid.me\/video\/8734973\/stream?format=dash",
            "width": null,
            "height": null,
            "version": 10
        }, {
            "type": "hls",
            "uri": "https:\/\/api.vid.me\/video\/8734973\/stream?format=hls",
            "width": null,
            "height": null,
            "version": 10
        }]
    }],
    "watching": {
        "8771660": 87,
        "8775629": 779,
        "8768903": 87,
        "8765873": 44,
        "8769371": 34,
        "8764733": 40,
        "8770856": 50,
        "8727017": 30,
        "8754326": 33,
        "8746172": 4,
        "8747912": 10,
        "6975323": 27,
        "8724479": 14,
        "8743094": 7,
        "8735804": 34,
        "8736356": 6,
        "8727716": 2,
        "8725823": 34,
        "8722406": 4,
        "8734973": 4
    },
    "viewerVotes": []
}
相关问题