[{bulkNo=91200256, cardType=CDMA_PP, denomination=300, endSerial=6048233, epfId=2254, nextSerialValue=6048226, startSerial=6048225}, {bulkNo=12050021, cardType=CDMA_PP, denomination=200, endSerial=6057151, epfId=2254, nextSerialValue=6057131, startSerial=6057131}, {bulkNo=12100005, cardType=CDMA_PP, denomination=100, endSerial=6003841, epfId=2254, nextSerialValue=6003842, startSerial=6003841}]
顯示了我GSON陣列時,我debug.need迭代它並創建從該如何迭代對象數組[Gson反序列化]?上述
此處對象表示我的代碼
Gson gson = new Gson();
List<SerialDetails> serialDetails =new ArrayList<SerialDetails>();
serialDetails = gson.fromJson(sendJsonDataList, ArrayList.class);
for(int i = 0 ; i < serialDetails.size() ; i++){
SerialDetails item = (SerialDetails) serialDetails.get(i);//ERROR COMES IN HERE
System.out.println(item);
}
和這裏示出了我的錯誤
java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to mainService.SerialDetails
at mainService.Sales.sendJsonDataList(Sales.java:677)
at mainService.TSR_WEB_SERVICE.sendJsonDataList(TSR_WEB_SERVICE.java:277)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
請幫我解決這個問題。我的bean類正確創建了getter和setter
適合我的情況。謝謝!!!! –