反序列化JSON数组列出WP7 [英] deserialize json array to list wp7
问题描述
我需要从子阵列内部的JSON中获取数据,但它没有得到转换成列表,下面是我的JSON字符串
i need to get data from sub-array inside json,but its not getting converted into list, below is my json string
{"response$c$c":"0","responseObject":{"TotalRecords":25,"TotalDisplayRecords":25,"aaData":[{"InvoiceId":16573,"somedata..}," appCrmAccount(一些标题,共100个这样的标题) 量:40086.00,invoiceNumber:12,帐户名:dfgAsfsadf,dueDateStr:2012年4月24日(数据成为进入名单)
{"responseCode":"0","responseObject":{"TotalRecords":25,"TotalDisplayRecords":25,"aaData":[{"InvoiceId":16573,"somedata..}," appCrmAccount(some title,total 100 such titles) amount":40086.00,"invoiceNumber":"12,accountName":"dfgAsfsadf"," dueDateStr":"04/24/2012"(data to be get into list)
这是我的code:
var djson = new DataContractJsonSerializer(typeof(dataList));
var stream = new MemoryStream(Encoding.UTF8.GetBytes(json));
dataList result = (dataList)djson.ReadObject(stream);//not getting execute
好心帮.. 在此先感谢。
kindly help.. Thanks in Advance.
推荐答案
究竟你需要做的是采取数组元素的回报作为DataContract和其子成员的数据成员为
what exactly you need to do is take array element return as a DataContract and its sub member as DataMember as
[DataContract]
public class mainresponse
{
[DataMember]
public resultmap arrayelement { get; set; }
}
[DataContract]
public class resultmap
{
[DataMember]
public string substringhere { get; set; }
}
var djson = new DataContractJsonSerializer(typeof(Mainresponse));
var stream = new MemoryStream(Encoding.UTF8.GetBytes(responsestring));
mainresponse result = (mainresponse)djson.ReadObject(stream);
这是...
这篇关于反序列化JSON数组列出WP7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!