|
- function arrayToJsonString(o,name) {
- var len = o.length;
- var new_arr = new Array();
- var str = '',strone='',strs='',jsonstr='';
- for(var i = 0;i<len;i++){
- new_arr = o[i];
- for(var k in new_arr){
- strone += '"'+k+'"'+':'+'"'+new_arr[k]+'"'+',';
- }
- str = '{'+strone.substring(0,strone.length-1)+'}';
- strone='';
- strs += str+','; 
- new_arr=[]; 
- }
- strs = '['+strs.substring(0,strs.length-1)+']';
- strs='{"'+name+'":'+strs+'}';
- return strs; 
- }
复制代码
调动方法:
- arrayToJsonString(data_Attach,"data_Attach"),
复制代码
结果:
- data_Attach: {"data_Attach":[{"0":"执行机构","1":"Nucom-10NM-20kgf.m 220V","2":"304+PTFE","3":"1","4":"0","5":"1","6":" "},{"0":"执行机构","1":"Nucom-10NS-5kgf.m 220V","2":"CD4MnCu","3":"2","4":"0","5":"2","6":" "},{"0":"手轮","1":"√","2":"CD4MnCu","3":"3","4":"0","5":"3","6":" "}]}
复制代码 |
|