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

Posted 淡紫色鍀薰衣草

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了添加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);

 

以上是关于添加json属性并赋值或修改json属性(ztree树形结构)的主要内容,如果未能解决你的问题,请参考以下文章

JS遍历类json对象属性值,方便统一赋值

JS遍历类json对象属性值,方便统一赋值

js中 给json对象添加属性和json数组添加元素

Jackson:如何在不修改 POJO 的情况下向 JSON 添加自定义属性

JQUERY操作JSON数组添加新的属性和值

nifi从json文件中获取属性