{
"App":[{
"AppID": 0,
"AppTime": "08:00 AM"
}],
"Rows": 0
}
這是我的JSON響應,但是當我映射到我的POJO類並訪問我時,我得到一個NullPointerException
。nullpointerexception映射pojo到json
ListResponse value = new Gson().fromJson(result, ListResponse.class);
import java.util.List;
public class ListResponse{
public List<AppList> appList;
public List<AppList> getAppList() {
return appList;
}
}
當我嘗試在我的活動類中訪問我的結果時,像這樣我得到一個錯誤。
public void accessData(ListResponse result){
System.out.println(result.getAppList()); // I am getting null here.
}
更新:
我APPLIST類包含,的AppID,AppTime and
行。
那是我還是你想要定義一個零長度的數組**在你的JSON中有**值? –
您的JSON對象沒有'appList'屬性,而是'App'屬性。 – BalusC
你解決問題了嗎? –