我有一个没有父级的JSON树,所以我无法获取属于他的发布数据,因为我的列表一直为空。我试图测试端点,一切看起来都很好。
这是JSON树:
{
"collection": {
"id": 239660,
"name": "Meditation Tools ☺️",
"title": "Apps, products, and hardware to help you relax when you need it most.",
"created_at": "2018-06-26T19:59:08.813-07:00",
"updated_at": "2018-07-05T06:50:45.032-07:00",
"featured_at": "2018-06-25T00:02:02.000-07:00",
"subscriber_count": 23,
"background_image_url": "https://ph-files.imgix.net/3b0a9b64-a3c3-4dcd-9af5-5160ed7c19c3?auto=format",
"category_id": null,
"collection_url": "https://www.producthunt.com/e/meditation-tools?utm_campaign=producthunt-api&utm_medium=api&utm_source=Application%3A+CarbonProjectKotlin+%28ID%3A+6168%29",
"color": "blue",
"posts_count": 17,
"user": {
"id": 92,
"created_at": "2013-12-05T18:00:02.471-08:00",
"name": "Product Hunt",
"username": "producthunt",
"headline": "",
"twitter_username": "ProductHunt",
"website_url": "http://producthunt.com/newsletter",
"profile_url": "https://www.producthunt.com/@producthunt",
"image_url": {
"30px": "https://ph-avatars.imgix.net/92/original?
"40px": "https://ph-avatars.imgix.net/92/original?auto=format&fit=crop&crop=faces&w=40&h=40",
"44px": "https://ph-avatars.imgix.net/92/original?
"64px": "https://ph-avatars.imgix.net/92/original?
"88px": "https://ph-avatars.imgix.net/92/original?
"110px": "https://ph-avatars.imgix.net/92/original?
"146px": "https://ph-avatars.imgix.net/92/original?auto=format&fit=crop&crop=faces&w=146&h=146",
"160px": "https://ph-avatars.imgix.net/92/original?
"original": "https://ph-avatars.imgix.net/92/original?auto=format&fit=crop&crop=faces&w=original&h=original"
}
},
"posts": [
{
"comments_count": 5,
"day": "2013-12-03",
"id": 85,
"name": "Calm",
"product_state": "default",
"tagline": "Take a break and meditate.",
"slug": "calm",
"ios_featured_at": null,
"votes_count": 424,
"category_id": null,
"created_at": "2013-12-03T18:56:34.009-08:00",
"current_user": {
"voted_for_post": false,
"commented_on_post": false
},
这是我的GSON模型课
data class Product(val id:Int,
val name:String,
val tagline:String,
@SerializedName("comments_count")
val commentsCount:Int,
@SerializedName("votes_count")
val votesCount:Int,
@SerializedName("screenshot_url")
val screenshotUrl:ScreenshotUrl,
@SerializedName("user")
val user:User)
data class ProductList(
@SerializedName("posts")
val product: List<Product>)
我的问题是,这是获取方式吗?