我正在使用 WCF 创建一个 Rest-JSON API。
问题是我的结果总是以{"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 结果中删除它吗?
提前致谢。