2013-03-04 94 views
0

是否可以在不使用System.ServiceModel.Web中的DataContractJsonSerializer的情况下将JSON字符串反序列化为对象?我有以下的代码,但我需要一个祈祷,许可使用它...将json反序列化为使用iPhone的单声道对象

response = (HttpWebResponse)request.EndGetResponse(iar); 
System.Runtime.Serialization.Json.DataContractJsonSerializer ser = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(Result)); 

Result result = (Result)ser.ReadObject(response.GetResponseStream()); 

回答

0

我使用RestSharp消耗是通过JSON发送数据我Web.API服务。但是,我使用JSON.NET来反序列化它。

_client.ExecuteAsync (request, (response) => { 

    List<Account> data = JsonConvert.DeserializeObject<List<Account>>(response.Content); 

这只是正常的我和JSON.NET是免费的,非常快的,善良的事实JSON序列库.NET的。

http://james.newtonking.com/projects/json-net.aspx

+0

谢谢,这似乎工作,但我仍然得到这个俗气的许可证错误http://cl.ly/NKPL ... – Marcus 2013-03-04 19:19:39

+1

FYI:System.Runtime.Serialization将被允许简化版在即将于下周发布的Xamarin Studio/Xamarin.iOS更新。 – jstedfast 2013-03-10 13:47:46