0
我的服務器響應是不同類型JSON對象的列表,這取決於每個響應的「類型」。每種響應類型都有不同的bean。可以使用適當的Bean類對列表中的每個響應(JSON對象)使用適當的Bean類(JSON數組)嗎?使用Retrofit2處理JSON數組中的多個JSON對象類型
{
"cards": [2]
0: {
"type": "A"
"ID": 24
"author_name": "ari"
"title": "BB"
"permalink": ""
"created_date": "2015-12-18 17:17:00"
"post_date": "Dec 18 2015"
"thumbnail": ""
"summary": "Stars"
"thumbSmall": "100.jpg"
"androidXL": "500.jpg"
}-
1: {
"type": "B"
"_id": "3290"
"read_count": 0
"categories": [1]
0: "abc"
"title": "New"
"isSticky": false
"section": [0]
"author": "zzz"
"india": false
"update_time": 1450415789694
"summary": "Social"
"scoreId": "nz"
"isActive": true
"image": ""
"timestamp": 1450385165210
"events": [1]
0: "nz"
"teams": [0]
"slug": "new"
"isDeleted": false
"score_str": "SL"
}
}
作爲一種變通方法,我創建了一個新的Bean類,與所有可能的領域,幾乎一半的字段都是空的每個JSON對象。
有沒有更好的方法來做到這一點?