0

我正在使用 TheMovieDatabase API 来获取有关电影的数据。我得到了超过 200 部电影的结果。数据格式如下:

{
    "results": [
        {
            "vote_count": 578,
            "id": 396422,
            "video": false,
            "vote_average": 6.4,
            "title": "Annabelle: Creation",
            "popularity": 201.166377,
            "poster_path": "/tb86j8jVCVsdZnzf8I6cIi65IeM.jpg",
            "original_language": "en",
            "original_title": "Annabelle: Creation",
            "genre_ids": [
                53,
                27
            ],
            "backdrop_path": "/o8u0NyEigCEaZHBdCYTRfXR8U4i.jpg",
            "adult": false,
            "overview": "Several years after the tragic death of their little girl, a dollmaker and his wife welcome a nun and several girls from a shuttered orphanage into their home, soon becoming the target of the dollmaker's possessed creation, Annabelle.",
            "release_date": "2017-08-03"
        },
        {
            "vote_count": 1489,
            "id": 324852,
            "video": false,
            "vote_average": 6.2,
            "title": "Despicable Me 3",
            "popularity": 111.345337,
            "poster_path": "/5qcUGqWoWhEsoQwNUrtf3y3fcWn.jpg",
            "original_language": "en",
            "original_title": "Despicable Me 3",
            "genre_ids": [
                878,
                12,
                16,
                35,
                10751
            ],
            "backdrop_path": "/puV2PFq42VQPItaygizgag8jrXa.jpg",
            "adult": false,
            "overview": "Gru and his wife Lucy must stop former '80s child star Balthazar Bratt from achieving world domination.",
            "release_date": "2017-06-15"
        },
        {
            "vote_count": 267,
            "id": 390043,
            "video": false,
            "vote_average": 6.4,
            "title": "The Hitman's Bodyguard",
            "popularity": 109.549201,
            "poster_path": "/5CGjlz2vyBhW5xHW4eNOZIdgzYq.jpg",
            "original_language": "en",
            "original_title": "The Hitman's Bodyguard",
            "genre_ids": [
                28,
                35
            ],
            "backdrop_path": "/dkA8j5DwUdUT3h658Mt1QgQHTR6.jpg",
            "adult": false,
            "overview": "The world's top bodyguard gets a new client, a hit man who must testify at the International Court of Justice. They must put their differences aside and work together to make it to the trial on time.",
            "release_date": "2017-08-16"
        }
    ]
}

如何获得特定元素?例如,我想从所有电影中获取 'title'、'release_date' 和 'poster_path' 放入二维表

4

1 回答 1

0

1.) Paste your JSON into [JSON to Object][1] .It will creates Object from your Json.

2.) Download the generated class and put it into your project.

3.) Crete getters and setters for the properties, then you will be able to get the properties. Ex. object.getTitle() will get the value of title.

于 2017-09-01T12:25:06.683 回答