我有一个JSON响应,如下所示:
interface API {
@Headers(
"Content-Type: application/json", "Authorization: token: String"
)
@POST("user/login/email")
fun login(@Body data: Data): Call<LoginResponse>
@GET("user/confirm")
fun confirm(@Header("authorization") token: String): Call<LoginResponse>
@PUT("punch/sign/{punchId}")
fun request(@Path("punchId") id: String): Call<String?>
}
我想做的是列出数据并获得reward.name
但是,在访问reward.name之前,有一个动态密钥,例如"response": {
"currentPage": 1,
"data": [
{
"id": 153289,
"goalId": 4623,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 8189,
"rewards": {
"5d8c2c245af58": {
"name": "Trip to Hokaido, Japan",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "100"
},
"5d8c2c245af5b": {
"name": "Meal Allowance for 1 month",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "90"
},
"5d8c2c245af5d": {
"name": "Parking Allowance for 1 month",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "80"
}
},
"intervalStartDate": "2019-10-25 00:00:00",
"intervalEndDate": "2019-10-25 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 130,
"goalItemTotal": 13,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 4623,
"name": "Goal 190926",
"interval": "Daily"
}
},
{
"id": 153274,
"goalId": 4617,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 8178,
"rewards": {
"5d8c2ade757eb": {
"name": "Trip to Hokaido, Japan",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "100"
},
"5d8c2ade757ef": {
"name": "Meal Allowance for 1 month",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "90"
},
"5d8c2ade757f1": {
"name": "Parking Allowance for 1 month",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "80"
}
},
"intervalStartDate": "2019-10-25 00:00:00",
"intervalEndDate": "2019-10-25 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 130,
"goalItemTotal": 13,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 4617,
"name": "Goal %",
"interval": "Daily"
}
},
{
"id": 152944,
"goalId": 8,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 1236,
"rewards": {
"5cb55b694c1b0": {
"name": "pgr1",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "20"
},
"5cb55b694c1b5": {
"name": "pgr2",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "40"
},
"5cb55b694c1b6": {
"name": "pgr3",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "60"
}
},
"intervalStartDate": "2019-10-25 00:00:00",
"intervalEndDate": "2019-10-25 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 6,
"goalItemTotal": 3,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 8,
"name": "PG-190416-1233",
"interval": "Daily"
}
},
{
"id": 152950,
"goalId": 21,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 32,
"rewards": {
"5cb5832dcee13": {
"name": "ggr1",
"description": null,
"rewardType": 0,
"reward": null,
"completionRate": "20"
},
"5cb5832dcee16": {
"name": "ggr2",
"description": null,
"rewardType": 0,
"reward": null,
"completionRate": "40"
},
"5cb5832dcee17": {
"name": "ggr3",
"description": null,
"rewardType": 0,
"reward": null,
"completionRate": "60"
}
},
"intervalStartDate": "2019-10-25 00:00:00",
"intervalEndDate": "2019-10-25 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 6,
"goalItemTotal": 3,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 21,
"name": "GG-190416-1523",
"interval": "Daily"
}
},
{
"id": 153118,
"goalId": 4509,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 7998,
"rewards": {
"5d8879398f27e": {
"name": "Meal Voucher",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "20"
},
"5d8879398f281": {
"name": "bank RM50",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "40"
}
},
"intervalStartDate": "2019-10-25 00:00:00",
"intervalEndDate": "2019-10-25 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 375,
"goalItemTotal": 4,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 4509,
"name": "Goal's in 31 September",
"interval": "Daily"
}
},
{
"id": 153133,
"goalId": 4511,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 8014,
"rewards": {
"5d8881526c231": {
"name": "Meal Voucher",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "20"
},
"5d8881526c236": {
"name": "bank RM50",
"description": null,
"rewardType": "1",
"reward": null,
"completionRate": "40"
}
},
"intervalStartDate": "2019-10-25 00:00:00",
"intervalEndDate": "2019-10-25 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 30,
"goalItemTotal": 2,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": "GT-190923 Project in Kuala Lumpur for new branch",
"goal": {
"id": 4511,
"name": "Goal 1-GT-190923",
"interval": "Daily"
}
},
{
"id": 153140,
"goalId": 4512,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 8015,
"rewards": {
"5d8881527479c": {
"name": "Meal Voucher",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "25"
},
"5d888152747a0": {
"name": "bank RM75",
"description": null,
"rewardType": "1",
"reward": null,
"completionRate": "50"
}
},
"intervalStartDate": "2019-10-25 00:00:00",
"intervalEndDate": "2019-10-25 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 3,
"goalItemTotal": 2,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": "GT-190923 Project in Kuala Lumpur for new branch",
"goal": {
"id": 4512,
"name": "Goal 2",
"interval": "Daily"
}
},
{
"id": 152993,
"goalId": 4434,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 8011,
"rewards": null,
"intervalStartDate": "2019-10-25 00:00:00",
"intervalEndDate": "2019-10-25 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 133,
"goalItemTotal": 4,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 4434,
"name": "HG-190920-1754",
"interval": "Daily"
}
},
{
"id": 139106,
"goalId": 1,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 6661,
"rewards": {
"5cb5595c50832": {
"name": "Meal Voucher",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "20"
},
"5cb5595c50836": {
"name": "bank RM50",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "40"
}
},
"intervalStartDate": "2019-10-21 00:00:00",
"intervalEndDate": "2019-10-27 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 30,
"goalItemTotal": 2,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 1,
"name": "Goal 1",
"interval": "Weekly"
}
},
{
"id": 139117,
"goalId": 2,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 4,
"rewards": {
"5cb5598746005": {
"name": "Meal Voucher",
"description": null,
"rewardType": 0,
"reward": null,
"completionRate": "25"
},
"5cb5598746009": {
"name": "baak RM75",
"description": null,
"rewardType": 0,
"reward": null,
"completionRate": "50"
}
},
"intervalStartDate": "2019-10-21 00:00:00",
"intervalEndDate": "2019-10-27 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 3,
"goalItemTotal": 2,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 2,
"name": "Goal 2",
"interval": "Weekly"
}
},
{
"id": 133427,
"goalId": 2,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 4,
"rewards": {
"5cb5598746005": {
"name": "Meal Voucher",
"description": null,
"rewardType": 0,
"reward": null,
"completionRate": "25"
},
"5cb5598746009": {
"name": "bank RM75",
"description": null,
"rewardType": 0,
"reward": null,
"completionRate": "50"
}
},
"intervalStartDate": "2019-10-14 00:00:00",
"intervalEndDate": "2019-10-20 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 3,
"goalItemTotal": 2,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 2,
"name": "Goal 2",
"interval": "Weekly"
}
},
{
"id": 133416,
"goalId": 1,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 6661,
"rewards": {
"5cb5595c50832": {
"name": "Meal Voucher",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "20"
},
"5cb5595c50836": {
"name": "bank RM50",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "40"
}
},
"intervalStartDate": "2019-10-14 00:00:00",
"intervalEndDate": "2019-10-20 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 30,
"goalItemTotal": 2,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 1,
"name": "Goal 1",
"interval": "Weekly"
}
},
{
"id": 113101,
"goalId": 4580,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 8125,
"rewards": null,
"intervalStartDate": "2019-10-01 00:00:00",
"intervalEndDate": "2019-10-31 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 101,
"goalItemTotal": 2,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 4580,
"name": "Goal Testing in %",
"interval": "Monthly"
}
},
{
"id": 151755,
"goalId": 4989,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 8740,
"rewards": {
"5dafd142455d9": {
"name": "Trip to Hokaido, Japan",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "100"
},
"5dafd142455dc": {
"name": "Meal Allowance for 1 month",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "90"
},
"5dafd142455de": {
"name": "Parking Allowance for 1 month",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "80"
}
},
"intervalStartDate": "2019-10-01 00:00:00",
"intervalEndDate": "2019-10-31 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 130,
"goalItemTotal": 13,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 4989,
"name": "Goal Achieved 01",
"interval": "Monthly"
}
},
{
"id": 107936,
"goalId": 1403,
"userId": 12,
"tenantId": 2,
"department": "Cleaning",
"status": 0,
"grandCompletedRate": "0.00",
"grandCompletedScore": "0.00",
"goalItemId": 7820,
"rewards": {
"5d30636e3062b": {
"name": "Meal Voucher",
"description": null,
"rewardType": "0",
"reward": null,
"completionRate": "25"
},
"5d30636e3062f": {
"name": "dddf RM75",
"description": null,
"rewardType": "1",
"reward": null,
"completionRate": "50"
}
},
"intervalStartDate": "2019-10-01 00:00:00",
"intervalEndDate": "2019-10-31 00:00:00",
"rewardStatus": 0,
"rewardedAmount": "0.00",
"deletedAt": null,
"totalItemsPoint": 78,
"goalItemTotal": 12,
"goalItemCompleted": 0,
"goalItemPending": 0,
"pendingApprovalSetting": "1",
"teamName": null,
"goal": {
"id": 1403,
"name": "190920-Goal's Testing for Character\"s",
"interval": "Monthly"
}
}
],
}
,5d8c2c245af58
等。
我试图生成数据模型,但这是我得到的:https://app.quicktype.io?share=dLZbMPMkhMpoYO4PiImr。
5d8c2c245af5b
我希望在ListView中显示数据列表,但我正在努力在数据模型中映射动态键