Sharepoint列表数据到Javascript对象文本

Sharepoint列表数据到Javascript对象文本,javascript,sharepoint,object-literal,Javascript,Sharepoint,Object Literal,我正在尝试将listdata转换为JS对象文字 输出应如下所示: dp.resources = [ { name: "Room A", id: "A", expanded: true, children:[ { name : "Room A.1", id : "A.1" }, { name : "Room A.2", id : "A.2" }

我正在尝试将listdata转换为JS对象文字

输出应如下所示:

dp.resources = [
                 { name: "Room A", id: "A", expanded: true, children:[
                         { name : "Room A.1", id : "A.1" },
                         { name : "Room A.2", id : "A.2" }
                         ] 
                 },
                 { name: "Room B", id: "B" },
                 { name: "Room C", id: "C" },
                 { name: "Room D", id: "D" },
                 { name: "Room E", id: "E" },
                 { name: "Room F", id: "F" },
                 { name: "Room G", id: "G" },
                 { name: "Room H", id: "H" },
                 { name: "Room I", id: "I" },
                 { name: "Room J", id: "J" },
                 { name: "Room K", id: "K" },
                ];
我使用此jquery代码加载主要房间:

dp.resources = [];
serviceUrl = "../_vti_bin/listdata.svc/Rooms()?$orderby=Order asc";
$.getJSON(serviceUrl, function(results) {
  $.each(results.d.results, function(i, item) {
   dp.resources.push({name:item.Title, id:item.Id, expanded: true, dynamicChildren: true});
  }); // end each
 dp.update();

现在,我如何从另一个列表中检索孩子(例如B.1),并将他们推到dp资源中的正确位置?我更喜欢将它嵌套到上面的$中。我脚本的每个部分

其他人似乎对此并不感兴趣,但以下是我使用jquery ajax从sharepoint列表加载daypilot数据的最终代码:

// load resources
dp.resources = [];
branchUrl = "../_vti_bin/listdata.svc/Branches()?$orderby=Order asc";
$.getJSON(branchUrl, function(results) {
  $.each(results.d.results, function(i, item) {
   dp.resources.push({name:item.Title, id:"b_" + item.Id, expanded: true, dynamicChildren: true, children:[]});

   // load children
   dp.onLoadNode = function(args) {
    args.async = true;
    resourceURL = "../_vti_bin/listdata.svc/Resources()?$filter=Titel+eq+'" + args.resource.name + "'";
     $.getJSON(resourceURL, function(results) {
      $.each(results.d.results, function(i, item) {
       args.resource.children.push({name:item.Name, id:"r_" + item.Id});
      }); // end each
     }).then(function(){
         args.loaded();  
        });
   }; //end onLoadNode


  }); // end each
}).then(function() {
 dp.update();
}); // end thens