java mar --->JSONArray.fromObject
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
----------------------------------------------------------------------
Object map = (Object)this.param.get("map");
int xx =1;
net.sf.json.JSONArray ja = net.sf.json.JSONArray.fromObject(map);
for(int i=0;i<ja.size();i++) {
net.sf.json.JSONObject obj1 = (net.sf.json.JSONObject)ja.getJSONObject(i);
logger.info("i="+i+","+obj1.get("menuid").toString()+",menuname:"+obj1.get("menuname").toString()+",icon:"+obj1.get("icon").toString()+",url:"+(obj1.get("url")==null?"":obj1.get("url").toString())+",parent_id:"+"0");
SysPowerMenu sysPowerMenu = new SysPowerMenu();
sysPowerMenu.setMenuid(obj1.get("menuid").toString());
sysPowerMenu.setMenuname(obj1.get("menuname").toString());
sysPowerMenu.setUrl((obj1.get("url")==null?"":obj1.get("url").toString()));
sysPowerMenu.setIcon(obj1.get("icon").toString());
sysPowerMenu.setParentId("0");
int i1 =sysPowerMenuService.add(sysPowerMenu);
xx+=1;
logger.info("==>insert into succes:"+(i1>0?"成功":"失败"));
if(obj1.get("menus")==null)
continue;
net.sf.json.JSONArray ja2 = net.sf.json.JSONArray.fromObject(obj1.get("menus"));
for(int j=0;j<ja2.size();j++) {
net.sf.json.JSONObject obj2 = (net.sf.json.JSONObject)ja2.getJSONObject(j);
logger.info("i="+j+","+obj2.get("menuid").toString()+",menuname:"+obj2.get("menuname").toString()+",icon:"+obj2.get("icon").toString()+",url:"+(obj2.get("url")==null?"":obj2.get("url").toString())+",parent_id:"+obj1.get("menuid").toString());
SysPowerMenu sysPowerMenu2 = new SysPowerMenu();
sysPowerMenu2.setMenuid(obj2.get("menuid").toString());
sysPowerMenu2.setMenuname(obj2.get("menuname").toString());
sysPowerMenu2.setUrl((obj2.get("url")==null?"":obj2.get("url").toString()));
sysPowerMenu2.setIcon(obj2.get("icon").toString());
sysPowerMenu2.setParentId(obj1.get("menuid").toString());
int i2 =sysPowerMenuService.add(sysPowerMenu2);
xx+=1;
logger.info("==>insert into succes:"+(i2>0?"成功":"失败"));
if(obj2.get("menus")==null)
continue;
net.sf.json.JSONArray ja3 = net.sf.json.JSONArray.fromObject(obj2.get("menus"));
for(int k=0;k<ja3.size();k++) {
net.sf.json.JSONObject obj3 = (net.sf.json.JSONObject)ja3.getJSONObject(k);
logger.info("k="+k+","+obj3.get("menuid").toString()+",menuname:"+obj3.get("menuname").toString()+",icon:"+obj3.get("icon").toString()+",url:"+(obj3.get("url")==null?"":obj3.get("url").toString())+",parent_id:"+obj2.get("menuid").toString());
SysPowerMenu sysPowerMenu3 = new SysPowerMenu();
sysPowerMenu3.setMenuid(obj3.get("menuid").toString());
sysPowerMenu3.setMenuname(obj3.get("menuname").toString());
sysPowerMenu3.setUrl((obj3.get("url")==null?"":obj3.get("url").toString()));
sysPowerMenu3.setIcon(obj3.get("icon").toString());
sysPowerMenu3.setParentId(obj2.get("menuid").toString());
int i3 =sysPowerMenuService.add(sysPowerMenu3);
xx+=1;
logger.info("==>insert into succes:"+(i3>0?"成功":"失败"));
if(obj3.get("menus")==null)
continue;
net.sf.json.JSONArray ja4 = net.sf.json.JSONArray.fromObject(obj3.get("menus"));
for(int m=0;m<ja4.size();m++) {
net.sf.json.JSONObject obj4 = (net.sf.json.JSONObject)ja4.getJSONObject(m);
logger.info("m="+m+","+obj4.get("menuid").toString()+",menuname:"+obj4.get("menuname").toString()+",icon:"+obj4.get("icon").toString()+",url:"+(obj4.get("url")==null?"":obj4.get("url").toString())+",parent_id:"+obj3.get("menuid").toString());
SysPowerMenu sysPowerMenu4 = new SysPowerMenu();
sysPowerMenu4.setMenuid(obj4.get("menuid").toString());
sysPowerMenu4.setMenuname(obj4.get("menuname").toString());
sysPowerMenu4.setUrl((obj4.get("url")==null?"":obj4.get("url").toString()));
sysPowerMenu4.setIcon(obj4.get("icon").toString());
sysPowerMenu4.setParentId(obj3.get("menuid").toString());
int i4 =sysPowerMenuService.add(sysPowerMenu4);
xx+=1;
logger.info("==>insert into succes:"+(i4>0?"成功":"失败"));
if(obj4.get("menus")==null)
continue;
net.sf.json.JSONArray ja5 = net.sf.json.JSONArray.fromObject(obj4.get("menus"));
for(int n=0;n<ja5.size();n++) {
net.sf.json.JSONObject obj5 = (net.sf.json.JSONObject)ja5.getJSONObject(n);
logger.info("n"+n+","+obj5.get("menuid").toString()+",menuname:"+obj5.get("menuname").toString()+",icon:"+obj5.get("icon").toString()+",url:"+(obj5.get("url")==null?"":obj5.get("url").toString())+",parent_id:"+obj4.get("menuid").toString());
SysPowerMenu sysPowerMenu5 = new SysPowerMenu();
sysPowerMenu5.setMenuid(obj5.get("menuid").toString());
sysPowerMenu5.setMenuname(obj5.get("menuname").toString());
sysPowerMenu5.setUrl((obj5.get("url")==null?"":obj3.get("url").toString()));
sysPowerMenu5.setIcon(obj5.get("icon").toString());
sysPowerMenu5.setParentId(obj4.get("menuid").toString());
int i5 =sysPowerMenuService.add(sysPowerMenu5);
xx+=1;
logger.info("==>insert into succes:"+(i5>0?"成功":"失败"));
if(obj5.get("menus")==null)
continue;
}
}
}
}
}