接口被调用 返回jsonArray 处理jsonArray数据

 
 @RequestMapping(value = "/querySource.htm", method = RequestMethod.POST)
public String init(HttpServletRequest request ) throws IOException {

Map<String, String> map = new HashMap<String, String>();
        Enumeration<?> fields = request.getParameterNames();

        while(fields.hasMoreElements())
        {
            String field = (String) fields.nextElement();
            String[] values = request.getParameterValues(field);
            if (values.length > 1)
                map.put(field, values.toString());
            else
                map.put(field, values[0]);
        }
        logger.info("***接口返回jsonArray:"+map.get("jsonArray"));




if(map.get("jsonArray")!=null && map.get("jsonArray").length()>0){
 String arrayStr = map.get("jsonArray");

            List<PostAccountVO> postAccountVOList = new ArrayList<PostAccountVO>();

            List<Map<String,String>> listObjectSec = JSONArray.parseObject(arrayStr,List.class);
            Map<String,String> mapList = new HashMap<String, String>();
            for(int i=0;i<listObjectSec.size();i++){
                mapList = listObjectSec.get(i);
                JSONObject jsonObject = JSONObject.fromObject(mapList);
                PostAccountVO postAccountVO=(PostAccountVO)JSONObject.toBean(jsonObject, PostAccountVO.class);
                postAccountVOList.add(postAccountVO);
            }
            logger.info("接口jsonArray数据转对象:"+postAccountVOList);


}


}

对方是以http的方式访问我的就接口

猜你喜欢

转载自fengxiaoshuang429201406254717.iteye.com/blog/2394719