日期:2014-05-17 浏览次数:20801 次
//////////////////////////////////////以下的应该是类似一个类的声明
[DataContract]
public class ResultgetProduct
{
[DataMember]
public string serialNumber { get; set; }
public string language { get; set; }//我新加的
public ResultgetProduct(string newserialNumber,string newsupportLanguage)
{
serialNumber = newserialNumber;
language = newsupportLanguage;//我新加的
}
}
[DataContract]
public class ResultRequestgetProduct
{
[DataMember]
public ResultgetProduct[] result;
}
/////////////////////////////////////////以下是一个解析的函数吧
public class getProductClass
{
public static ResultRequestgetProduct ReadToObject(string json)
{
ResultRequestgetProduct deserializedUser = new ResultRequestgetProduct();
try
{
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json));
DataContractJsonSerializer ser = new DataContractJsonSerializer(deserializedUser.GetType());
deserializedUser = ser.ReadObject(ms) as ResultRequestgetProduct;
ms.Close();
}
catch (Exception e)
{ }
return deserializedUser;
}
}