List<Stock> stocks = new ArrayList<Stock>();for(int i = 0; i<8;i++){Stock s = new Stock();s.setCode("00001"+r.nextInt(10));s.setName("万达A"+r.nextInt(10));s.setPrice(r.nextInt(100));stocks.add(s);}//对象组成的集合或数组的转换JSONArray arr = JSONArray.fromObject(stocks);