import net.sf.json.JSONArray;import net.sf.json.JSONObject;@Testpublic void stringToArrayObject() {String jsonStr = "[{\"activityName\":\"双十一活动1\",\"channleActivityId\":\"1000197\"}," + "{\"activityName\":\"双十一活动2\",\"channleActivityId\":\"1000197\"}]";JSONArray jsonArray = JSONArray.fromObject(jsonStr);for (int i = 0; i < jsonArray.size(); i++) {JSONObject jsonObject = jsonArray.getJSONObject(i);ActivityDTO dto = (ActivityDTO)JSONObject.toBean(jsonObject,ActivityDTO.class);LOG.info("dto:{}", dto);}}
1200字范文,内容丰富有趣,写作的好帮手!