开发者

How to deserialize JSON returned by WCF Data Service (OData)

An external OData Service returns the following during a POST operation (for a service operation):

{
"d" : {
"__meta开发者_如何转开发data": {
"uri": "http://dd-1620/ServiceData.svc/Customers('1001')", "type": "DataModel.Customer"
}, "MasterCustomerId": "1001", "SubCustomerId": "0", "FirstName": "Jag", "LastName": "Chat"
}
}   

I wrote the following to deserialize the above:

HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream respStream = resp.GetResponseStream();
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ReturnType));
ReturnType oRespCus = (ReturnType)ser.ReadObject(respStream);

Now, oRespCus is indeed instantiated. However, with all fields set to null.

Can anyone help me on this.

thanks


For those who do not know, I would like to share the answer I received from here

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/55b6f018-2944-4160-8393-62a14376c361

thanks all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜