Android 如何在retofit库中获得这种类型的响应?

Android 如何在retofit库中获得这种类型的响应?,android,Android,最好的方法是使用GSON 在gradle.build中添加GSON依赖项 为上面显示的响应创建GSON类。您可以使用此在线工具进行以下操作- 将改装响应类型设置为该级别 这样,您就可以通过改型获得上述响应类型。在发布问题时,请确保解释您的问题并尝试解决您的问题。您的问题代码格式也很差,请更正,因为这会使问题看起来很差。请参阅了解如何在问题中正确添加代码段。 { "status": "ok", "count": 2, "pages": 1, "category":

最好的方法是使用GSON

  • 在gradle.build中添加GSON依赖项
  • 为上面显示的响应创建GSON类。您可以使用此在线工具进行以下操作-
  • 将改装响应类型设置为该级别

  • 这样,您就可以通过改型获得上述响应类型。在发布问题时,请确保解释您的问题并尝试解决您的问题。您的问题代码格式也很差,请更正,因为这会使问题看起来很差。请参阅了解如何在问题中正确添加代码段。
    {
        "status": "ok",
        "count": 2,
        "pages": 1,
        "category": {
            "id": 5,
            "slug": "campus",
            "title": "Campus",
            "description": "",
            "parent": 0,
            "post_count": 2
        },
        "posts": [
            {
                "id": 42,
                "type": "post",
    
                "url": "http://jantasamachar.com/changing-rajya-sabha-presents-modi-with-unique-opportunity-to-unleash-reforms/",
                "status": "publish",
                "title": "Changing Rajya Sabha presents Modi with unique opportunity to unleash reforms",
    
                "content":
     "date": "2017-08-02 07:00:28",
                "modified": "2017-08-02 07:10:48",
                "categories": [
                    {
                        "id": 5,
                        "slug": "campus",
                        "title": "Campus",
                        "description": "",
                        "parent": 0,
                        "post_count": 2
                    }
                ],
                "tags": [],
                "author": {
                    "id": 1,
                    "slug": "admin",
                    "name": "admin",
                    "first_name": "",
                    "last_name": "",
                    "nickname": "admin",
                    "url": "",
                    "description": ""
                },
                "comments": [],
                "attachments": [],
                "comment_count": 0,
                "comment_status": "open",
    
                "custom_fields": {
                    "post_media_position": [
                        "media_full_width"
                    ],
                    "homepage_slider_add": [
                        "1"
                    ],
                    "featured_post_add": [
                        "1"
                    ],
                    "category_slider_add": [
                        "1"
                    ],
                    "post_sidebar": [
                        "post_sidebar_on"
                    ],
                    "enable_rating": [
                        "0"
                    ]
                },
                "thumbnail_size": "thumbnail",
                "thumbnail_images": {
                    "full": {
                        "url": "http://jantasamachar.com/wp-content/uploads/2017/08/nation-1.jpg",
                        "width": 1900,
                        "height": 600
                    },
                    "thumbnail": {
                        "url": "http://jantasamachar.com/wp-content/uploads/2017/08/nation-1-150x150.jpg",
                        "width": 150,
                        "height": 150
                    },
                    "medium": {
                        "url": "http://jantasamachar.com/wp-content/uploads/2017/08/nation-1-300x95.jpg",
                        "width": 300,
                        "height": 95
                    },
                    "medium_large": {
                        "url": "http://jantasamachar.com/wp-content/uploads/2017/08/nation-1-768x243.jpg",
                        "width": 768,
                        "height": 243
                    },
                    "large": {
                        "url": "http://jantasamachar.com/wp-content/uploads/2017/08/nation-1-1024x323.jpg",
                        "width": 1024,
                        "height": 323
                    }
                }
            },