加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 18:51:42 所属栏目:百科 来源:网络整理
导读:@RequestMapping(value = "/querySource.htm",method = RequestMethod.POST)public String init(HttpServletRequest request ) throws IOException {MapString,String map = new HashMapString,String(); Enumeration? fields = request.getParameterNames()
 
 @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的方式访问我的就接口

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读