0
我遇到了一個問題,同時將我的iOS應用程序轉換爲android。通用ParseFile對象的JSON對象,問題
數據庫的結構使得有「站點」,這些站點可以有多個附加的圖像,在解析數據庫中,圖像是一個imagePointers數組。
當我希望得到這些圖片,iOS中這裏是我做過什麼:
站=在這種情況下,對象
// Get a single image
if ([[object objectForKey:@"imagePointers"] objectAtIndex:0] != [NSNull null]) {
PFFile *imageFile = [[[object objectForKey:@"imagePointers"] objectAtIndex:0] objectForKey:@"image"];
cell.coverImageView.file = imageFile;
[cell.coverImageView loadInBackground];
}
它很簡單,我只是舉imagePointers陣列,並得到objectAtIndex0 ,然後我把它轉換成一個解析文件。
但我不能在Android中做到這一點,這裏是我有個大氣壓:
JSONArray imagePointers = thisStation.getJSONArray("imagePointers");
try {
JSONObject indexImage = imagePointers.getJSONObject(0);
} catch (Exception e) {
JSONObject indexImage = null;
}
這裏我得到的對象在索引0作爲一個JSONObject,我不能在ParseFile對象使用,因爲我需要把它作爲一個泛型類型ParseFile。
我該怎麼做?或者我的方法完全不正確?