這裏是一個WCF方法發送JSON格式的響應。如何更改JSON響應格式
[OperationContract(Name = "Employee")]
[WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedResponse, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, UriTemplate = "person/{name}")]
Person GetPersonData(string name);
這是我收到的格式:
{ 「EmployeeResult」:{ 「時代」:31, 「姓名」: 「testuser的」}}
我需要像下面的東西:
{ 「員工」:{ 「時代」:31, 「姓名」: 「testuser的」}}
我試圖改變
BodyStyle = WebMessageBodyStyle.Bare
,但得到如下格式:
{ 「時代」:31, 「姓名」: 「testuser的」 }
是否有任何其它的事情,我需要改變嗎?我工作的.NET Framework 4.5
感謝
你檢查這http://stackoverflow.com/questions/20206069/restful-web-service -body-format/20225936#20225936? – Rockstar