1:JSON格式数据如下
{"ticketInfos":[{"name":"刚刚","menPiaoType":"免费门票","price":0},{"name":"刚刚","menPiaoType":"免费门票","price":0}]}
if (etc.getTicketDetailJson() != null && "".equals(etc.getTicketDetailJson())) { JSONObject myJsonObject = new JSONObject(etc.getTicketDetailJson()); JSONArray jsonarry = (JSONArray) myJsonObject.get("ticketInfos"); for (int i = 0; i < jsonarry.length(); i++) { TicketDetail ticketDetail = new TicketDetail(); JSONObject jObject = (JSONObject) jsonarry.get(i); ticketDetail.setName(jObject.get("name").toString()); ticketDetail.setMenPiaoType(jObject.getString("menPiaoType").toString()); price = Integer.parseInt(jObject.get("price").toString()); break; } }