动态创建json for treeview

时间:2014-02-07 01:17:41

标签: json dynamic treeview

我想转json

var treeNodes = [ {managerid:root,Employeeid:01}, 
                  {managerid:01,Employeeid:11}, 
                  {managerid:01,Employeeid:22}, 
                  {managerid:22,Employeeid:33}, 
                  {managerid:22,Employeeid:44} 
                ]; 

使用javascript这样进入json。

json={
  id:root,
  children[{
       id:01,
       children[
               {id:11},
               {id:22}
       ]
       children[
               {id:33},
               {id:44}
       ]
 }

有人可以帮助使用java脚本功能吗?

1 个答案:

答案 0 :(得分:1)

首先,您当前的JSON不正确:

var json = {
   id: root, 
   children: [
         { 
            id: 01,
            children: [
               {id: 11},
               {id: 22} 
            ]
         }, 
         {
            children: [
               {id: 33},
               {id: 44} 
            ]
         }
      ]
   };

其次,您能否提供有关表Employee的更多信息?