2013-10-28 80 views
0
{ 
"allnodes":[ 
{ 
    "nodes":[ 
     { 
      "data":{ 
      "parentId":"1", 
      "nodes":[ 

      ], 
      "name":"a", 
      "nodescount":0, 
      "id":"2" 
      } 
     }, 
     { 
      "data":{ 
      "parentId":"1", 
      "nodes":[ 
       { 
        "data":{ 
         "parentId":"3", 
         "nodes":[ 

         ], 
         "name":"b", 
         "nodescount":0, 
         "id":"4" 
        } 
       } 
      ], 
      "name":"c", 
      "nodescount":1, 
      "id":"3" 
      } 
     } 
    ], 
    "name":"d", 
    "nodescount":2, 
    "id":"1" 
    } 
    ] 
} 

.NET數據合同json to .net class n-ary tree?

[DataContract] 
    class Node 
    { 
     [DataMember(Name = "id")] 
     public string id { get; set; } 

     [DataMember(Name = "name")] 
     public string name { get; set; } 

     [DataMember(Name = "parentId")] 
     public string ParentId { get; set; } 

     [DataMember(Name = "nodescount")] 
     public long Nodescount { get; set; } 

     [DataMember(Name = "nodes")] 
     public IEnumerable<Node> Nodes { get; set; } 
    } 

WCF其餘呼叫

 [WebGet(UriTemplate = "/abc/nodes", 
    RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, 
    BodyStyle = WebMessageBodyStyle.Wrapped)] 
    void GetNodeTree(, 
    [MessageParameter(Name = "allnodes")] 
    out Node[] items); 

問題: 我有問題是,內部節點不裝載有正確的信息,頂層的作品,我似乎無法得到我在datacontrac中缺少的東西T'

回答

0

節點類工作完美一旦予刪除的對象,因爲這是多餘的

「數據」:{}