1. 程式人生 > >將一個物件集合轉換成JSON格式

將一個物件集合轉換成JSON格式

List<ServiceWorkOrder> serviceWorkOrderList = new ArrayList<ServiceWorkOrder>();
        //轉換成JSON各式
        JSONArray jsonArray = JSONArray.fromObject(jsonStr);
        //轉換成serviceWorkOrder物件集合
        serviceWorkOrderList = (ArrayList)JSONArray.toCollection(jsonArray, ServiceWorkOrder.class);