0
當我使用Retrofit進行API調用時,我得到了下面的JSON響應。使用Retrofit和Gson解析Json數據
現在我想將數據映射到模型。什麼是最好的方式來做到這一點?提前致謝。
編輯:這是真正的JSON響應。
{
"status": "success",
"data": {
"messages": [],
"result": {
"clinicCode": "Medics",
"firstName": "Charles",
"lastName": "Sanders",
"officeId": 0,
"id": 7811,
"startDate": 1508139082929,
"timeZoneId": 0,
"userDetailId": 6,
"userName": "charles",
"jobTitle": {
"id": 1,
"text": "Doctor",
"count": 1
},
"isSuperUser": false,
"clientId": 10,
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGluaWNDb2RlIjoiTWVkaWNzIiwiZW1haWwiOm51bGwsImVuZERhdGUiOm51bGwsImZpcnN0TmFtZSI6IkNoYXJsZXMiLCJsYXN0TmFtZSI6IlNhbmRlcnMiLCJvZmZpY2VJZCI6MCwiaWQiOjc4MTEsInNwZWNpYWx0eUlkIjpudWxsLCJzdGFydERhdGUiOjAsInRpbWVab25lSWQiOjAsInVzZXJEZXRhaWxJZCI6NiwidXNlck5hbWUiOiJjaGFybGVzIiwib2ZmaWNlIjpudWxsLCJzcGVjaWFsdHkiOm51bGwsInRpbWVab25lIjpudWxsLCJ1c2VyRGV0YWlsIjpudWxsLCJwYXJhbWV0ZXJzIjpudWxsLCJqb2JUaXRsZSI6bnVsbCwiaXNTdXBlclVzZXIiOmZhbHNlLCJjbGllbnRJZCI6MTAsImNvZGUiOm51bGwsInRva2VuIjpudWxsLCJlbXBsb3llZUlkIjoxNCwicHJvdmlkZXJJZCI6bnVsbCwiaXNBY3RpdmUiOmZhbHNlLCJpc0xvY2tlZCI6ZmFsc2UsImxhc3RQYXNzd29yZENoYW5nZWQiOjAsImxvY2tlZENvZGVJZCI6bnVsbCwibG9ja2VkRGF0ZVRpbWUiOm51bGwsInBhc3N3b3JkIjpudWxsLCJwYXRpZW50SWQiOm51bGwsInByZWZMYW5nSWQiOm51bGwsInNlc3Npb25JZCI6NzgxMSwiY3JlYXRlZEJ5IjpudWxsLCJlbXBsb3llZSI6bnVsbCwibGFzdE1vZGlmaWVkQnkiOm51bGwsImxvY2tlZENvZGUiOm51bGwsInBhdGllbnQiOm51bGwsInByZWZMYW5nIjpudWxsLCJhcHBsaWNhdGlvbk5hbWUiOm51bGwsIm1hY2hpbmVJZCI6bnVsbCwibGFuZ0lkIjpudWxsLCJjb3VudHJ5Q29kZSI6IlVTIn0.Zd0TwwjP_HjzfgQzfS_-QIAXQ1F8TNTxFMSpve5VRWo",
"employeeId": 14,
"isActive": false,
"isLocked": false,
"lastPasswordChanged": 0,
"sessionId": 0
}
}
}
使用http://www.jsonschema2pojo.org/爲你生成POJO json迴應 –
你可以發佈真正的Jso n代替屏幕截圖 – Rahul
您可以在android工作室中下載gsonFormat插件,將響應映射到您的模型類 – AbhayBohra