1
我正在使用WCF創建Rest-JSON API。WCF響應始終以「GetResult」開頭
的問題是,我的結果總是與{"GetResult": HERE_MY_RESULT }
開始(注意 「調用getResult」)
例如:
public string GetString()
{
return "Hello World!";
}
回報{"GetResult": "Hello World!"}
下面是相關的代碼,我使用我的服務: 服務:
[ServiceContract]
public interface IPlaceService
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "places")]
PlaceModel Get();
}
public class PlaceService : IPlaceService
{
public PlaceModel Get()
{
return new PlaceModel
{
Count = 123,
Title = "Title",
Description = "Desc",
};
}
}
合同:
[DataContract]
public class PlaceModel
{
[DataMember(Name="count")]
public int Count { get; set; }
[DataMember(Name = "title")]
public string Title { get; set; }
[DataMember(Name = "description")]
public string Description { get; set; }
}
而結果:
{"GetResult":{"count":123,"description":"Desc","title":"Title"}}
有誰知道如何刪除"GetResult"
從我的JSON結果?
在此先感謝。