添加json属性并赋值或修改json属性(ztree树形结构)

var data=[
    {accounts :[],
    attrs : {maxmailboxsize: "-1", maxusers: "-1"},
    fullpath : "",id :"og59fdbc30578",
    modifytime : "", name:"123", poid : "", children : []
},
    {accounts :[],
        attrs : {maxmailboxsize: "-1", maxusers: "-1"},
        fullpath : "",id :"og59fdbc30578",
        modifytime : "",
        name:"开发部",
        poid : "",
        children : [{
            accounts :[],
            attrs : {maxmailboxsize: "开发部1", maxusers: "-1"},
            fullpath : "",id :"og59fdbc30578",
            modifytime : "",
            name:"开发部1",
            poid : "",
            children : [{accounts :[],
                attrs : {maxmailboxsize: "开发部11", maxusers: "-1"},
                fullpath : "",id :"og59fdbc30578",
                modifytime : "",
                name:"开发部11",
                poid : "",
                children : [{
                    accounts :[],
                    attrs : {maxmailboxsize: "-1", maxusers: "-1"},
                    fullpath : "",id :"og59fdbc30578",
                    modifytime : "",
                    name:"开发部111",
                    poid : "",
                    children : [{
                        accounts :[],
                        attrs : {maxmailboxsize: "-1", maxusers: "-1"},
                        fullpath : "",id :"og59fdbc30578",
                        modifytime : "",
                        name:"开发部1111",
                        poid : "",
                        children : [{
                            accounts :[],
                            attrs : {maxmailboxsize: "-1", maxusers: "-1"},
                            fullpath : "",id :"og59fdbc30578",
                            modifytime : "",
                            name:"开发部1111",
                            poid : "",
                            children : [{
                                accounts :[],
                                attrs : {maxmailboxsize: "-1", maxusers: "-1"},
                                fullpath : "",id :"og59fdbc30578",
                                modifytime : "",
                                name:"开发部111111",
                                poid : "",
                                children : []
                            }]
                        }]
                    }]
                }]
            }]
        }]
    }
];

if(data != "" && data.length>0){
    for(var i=0;i<data.length;i++){
      console.log(data[i]);
      var s = data[i];
      s["subditems"]=s.children;
        console.log(s);
    }
}
console.log(data);

 

posted @ 2017-11-16 19:03  淡紫色鍀薰衣草  阅读(1027)  评论(0编辑  收藏  举报