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 数据合约

  [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);

问题: 我遇到的问题是内部节点没有加载正确的信息,顶级工作,我似乎无法得到我的数据合同中缺少的东西?

4

1 回答 1

0

一旦我删除了对象,节点类就可以完美运行,因为这是多余的

“数据”:{ }

于 2013-11-01T23:22:25.167 回答