日期:2014-05-16  浏览次数:20380 次

js中json格式转换
在js中获取到

var json = 
[
    {
          "cId":"0011",
          "cName":"aaa",
          "list":[
                 {"dId":"0001","dName":"监查审计部","deptList":[]},
                 {"dId":"Dpt0002","dName":"财务部","deptList":[]
                 ]
     },
    {
          "cId":"0001",
          "cName":"bbb",
          "list":[
                 ]
     }
]


想把他转成


var newJson = {
                 id:"0011",
                 name:"aaa",
                 children:[
                            {
                              id:"0001",
                              name:"监查审计部",
                              children:[]
                             },
                            {
                               id:"Dpt0002",
                               name:"财务部",