日期:2014-05-16 浏览次数:20437 次
/// <summary>
/// 反序列化
/// </summary>
/// <typeparam name="T">类型</typeparam>
/// <param name="sJson">json字符串</param>
/// <returns></returns>
public static T Deserialize<T>(string sJson)
{
DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(T));
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(sJson));
T obj = (T)ds.ReadObject(ms);
ms.Close();
return obj;
}