201402220854小结

1.对于大量json数据用json格式化工具进行格式化

2.对于大量数据的解析先要弄清楚其规则和结构

3.对于json数据的解析

//这里面的F_SIMULATIONS存的是一个个节点,每一个节点包含{"F_NODE_ID":"9DDD0BEC39F21114EF525DEC80B2D213","F_NODE_NAME":"制单","F_NODE_USERS":[],"F_NODE_ROLES":[{"F_ROLE_ID":"SELF","F_ROLE_NAME":"本人"}],"F_USER_INFOS":[]},信息,我们需要做的是遍历节点,将每一个信息弄出来

data={"F_FLOW_ID":"CI3011","F_CODE":"0","F_MESSAGE":"","F_SIMULATIONS":[{"F_NODE_ID":"9DDD0BEC39F21114EF525DEC80B2D213","F_NODE_NAME":"制单","F_NODE_USERS":[],"F_NODE_ROLES":[{"F_ROLE_ID":"SELF","F_ROLE_NAME":"本人"}],"F_USER_INFOS":[]},{"F_NODE_ID":"9DDD0CE7DA07EC7F4F007A734F3A43D0","F_NODE_NAME":"财务会计审核","F_NODE_USERS":[],"F_NODE_ROLES":[{"F_ROLE_ID":"R009","F_ROLE_NAME":"财务会计"}],"F_USER_INFOS":[{"F_USER_ID":"0070","F_USER_NAME":"章馨予","F_ORG_ID":"100021","F_PROJECT_ID":""},{"F_USER_ID":"0065","F_USER_NAME":"符一鸣","F_ORG_ID":"100021","F_PROJECT_ID":""},{"F_USER_ID":"0063","F_USER_NAME":"常湘宇","F_ORG_ID":"100021","F_PROJECT_ID":""},{"F_USER_ID":"0071","F_USER_NAME":"张静","F_ORG_ID":"100021","F_PROJECT_ID":""},{"F_USER_ID":"0066","F_USER_NAME":"刘晓红","F_ORG_ID":"100021","F_PROJECT_ID":""},{"F_USER_ID":"0067","F_USER_NAME":"钟秀梅","F_ORG_ID":"100021","F_PROJECT_ID":""},{"F_USER_ID":"0069","F_USER_NAME":"曹华冰","F_ORG_ID":"100021","F_PROJECT_ID":""}]},{"F_NODE_ID":"9DDD0C89D9CC32460F2C0D402DD292DD","F_NODE_NAME":"部门经理审核","F_NODE_USERS":[],"F_NODE_ROLES":[{"F_ROLE_ID":"R008","F_ROLE_NAME":"部门经理"}],"F_USER_INFOS":[]},{"F_NODE_ID":"9DDD0D730A7EE9343FA7DEEA969FFCFA","F_NODE_NAME":"财务经理审核","F_NODE_USERS":[],"F_NODE_ROLES":[{"F_ROLE_ID":"R007","F_ROLE_NAME":"财务经理"}],"F_USER_INFOS":[{"F_USER_ID":"0030","F_USER_NAME":"刘华焕","F_ORG_ID":"100005","F_PROJECT_ID":""}]},{"F_NODE_ID":"9DDD0E9B68E3BA9EF6D99F824304551C","F_NODE_NAME":"主管业务领导","F_NODE_USERS":[],"F_NODE_ROLES":[{"F_ROLE_ID":"R006","F_ROLE_NAME":"主管业务领导(副总)"}],"F_USER_INFOS":[{"F_USER_ID":"0011","F_USER_NAME":"许佑君","F_ORG_ID":"100001","F_PROJECT_ID":""}]},{"F_NODE_ID":"9DDD0DD14A378F26C927433B3EE70A38","F_NODE_NAME":"财务总监审核","F_NODE_USERS":[],"F_NODE_ROLES":[{"F_ROLE_ID":"R002","F_ROLE_NAME":"财务总监"}],"F_USER_INFOS":[{"F_USER_ID":"0010","F_USER_NAME":"孟宪莹","F_ORG_ID":"","F_PROJECT_ID":""}]},{"F_NODE_ID":"9DDD0E2EDF435D978C93273AF6E04529","F_NODE_NAME":"总经理审核","F_NODE_USERS":[],"F_NODE_ROLES":[{"F_ROLE_ID":"R005","F_ROLE_NAME":"总经理"}],"F_USER_INFOS":[]},{"F_NODE_ID":"9DDD0F574B664727B01FD6768F15B687","F_NODE_NAME":"区域财务总监审核","F_NODE_USERS":[],"F_NODE_ROLES":[{"F_ROLE_ID":"R004","F_ROLE_NAME":"区域财务总监"}],"F_USER_INFOS":[]},{"F_NODE_ID":"9DDD0FC411AB16BBC3037CA80357FFAD","F_NODE_NAME":"区域总经理审批","F_NODE_USERS":[],"F_NODE_ROLES":[{"F_ROLE_ID":"R003","F_ROLE_NAME":"区域总经理"}],"F_USER_INFOS":[{"F_USER_ID":"0013","F_USER_NAME":"王连玉","F_ORG_ID":"100012","F_PROJECT_ID":""},{"F_USER_ID":"0012","F_USER_NAME":"李宝奎","F_ORG_ID":"100012","F_PROJECT_ID":""}]}]}


function creatdoms(data){
var F_SIMULATIONS = data.F_SIMULATIONS;
var nodesdom = $("#nodes");
$.each(F_SIMULATIONS,function(a,b){//遍历每一个节点
var F_NODE_ID=b.F_NODE_ID;
var F_NODE_NAME=b.F_NODE_NAME;
var F_NODE_USERS=b.F_NODE_USERS;
var F_NODE_ROLES=b.F_NODE_ROLES;
var F_USER_INFOS=b.F_USER_INFOS;
var nodediv=$("<div class=class='nodediv' />");
var n=a+1;//自制单节点开始,序号递增(=(索引+1))
//添加节点名字
var nodediv1=$("<div class='nodediv1'><span style='font-weight: bold;'>("+n+")"+F_NODE_NAME+"</span></div>");
//添加审批人
var nodediv2=$("<div class='nodediv2'><span style='font-weight: bold;'>审批人:</span></div>");
$.each(F_USER_INFOS,function(c,d){
var F_USER_NAME=d.F_USER_NAME;
var F_USER_ID=d.F_USER_ID;
var nodediv21=$("<span style='font-weight: bold;'>"+F_USER_NAME+"("+F_USER_ID+")</span>");
nodediv2.append(nodediv21);
}) 

//添加节点配置角色
var nodediv3=$("<div class='nodediv3'><span style='font-weight: bold;'>配置角色:</span></div>");
$.each(F_NODE_ROLES,function(e,f){
var F_ROLE_ID=f.F_ROLE_ID;
var F_ROLE_NAME=f.F_ROLE_NAME;
var nodediv31=$("<span style='font-weight: bold;'>"+F_ROLE_NAME+"("+F_ROLE_ID+")</span>");
nodediv3.append(nodediv31);
}) 
//添加节点配置用户
var nodediv4=$("<div class='nodediv4'><span style='font-weight: bold;'>配置用户:</span></div>");
$.each(F_NODE_USERS,function(g,h){
var F_USER_ID=h.F_USER_ID;
var F_USER_NAME=h.F_USER_NAME;
var nodediv41=$("<span style='font-weight: bold;'>"+F_USER_NAME+"("+F_USER_ID+")</span>");
nodediv4.append(nodediv41);
}) 
nodediv.append(nodediv1);
nodediv.append(nodediv3);
nodediv.append(nodediv4);
nodediv.append(nodediv2);
nodesdom.append(nodediv);



})
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值