【发布时间】:2011-10-28 15:45:31
【问题描述】:
我的问题与JsonConvert.DeserializeObject and "d" wrapper in WCF 类似,但我不确定如何针对我的情况实施此问题。这是我完整的 web.config WCF 数据服务:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="MyWcfDataService.svc">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="MyWcfDataServiceBehavior">
<webHttp defaultOutgoingResponseFormat="Json"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</location>
</configuration>
我的数据服务很简单:
// specifying WebMessageBodyStyle.Bare doesn't seem to have any effect
[WebGet(ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle=WebMessageBodyStyle.Bare)]
public string GetJsonTest(string x)
{
var json = new
{
hello = "world"
};
return new JavaScriptSerializer().Serialize(json);
}
【问题讨论】:
标签: .net json c#-4.0 wcf-data-services