我想使用GSon库将JSONArray序列化为ArrayList,结果结构为JSONArray-> JSONArray-> JSONObject
//I have tried this,
try {
Gson gson = new Gson();
Type placeOrdersListType = new
TypeToken<List<PlaceOrderMaster>>
() {
}.getType();
List<PlaceOrderMaster> placeOrdersTypeList =
gson.fromJson(jsonObject
.getJSONArray(ResponseParams.RESULT).toString(),
placeOrdersListType);
ArrayList<PlaceOrderMaster> arrayList = new ArrayList<>
(placeOrdersTypeList);
} catch (Exception e) {
e.printStackTrace();
}
//and my model class is like this,
private ArrayList<ArrayList<PlaceOrders>> result;
// API Response like this
{
"status": 1,
"message": "Order Placed successfully!!!",
"result": [
[
{
"orderid": "1841",
"category_id": "8"
},
{
"orderid": "1841",
"category_id": "1"
}
],
[
{
"orderid": "1842",
"category_id": "6"
},
{
"orderid": "1842",
"category_id": "6"
}
]
]
}
是否可以序列化API响应>?如果是,那怎么办?