反序列化JSON数组列出WP7数组、序列化、JSON

由网友(梦带我旅行i)分享简介:我需要从子阵列内部的JSON中获取数据,但它没有得到转换成列表,下面是我的JSON字符串i need to get data from sub-array inside json,but its not getting converted into list, below is my json string{"re...

我需要从子阵列内部的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);  

这是...

阅读全文

相关推荐

最新文章