标签:des http ar on ad ef as tt new
/// <summary>
/// JSON反序列化
/// </summary>
public static T JsonDeserialize<T>(string jsonString)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
T obj = (T)ser.ReadObject(ms);
return obj;
}
// List<shopMode> obj = util.HttpWeb.DeserializeFromJson<List<shopMode>>(r);
/// <summary>
/// JSON反序列化集合
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="jsonString"></param>
/// <returns></returns>
public static T DeserializeFromJson<T>(string jsonString) where T : class
{
DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(T));
using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)))
{
T obj = (T)ds.ReadObject(ms);
return obj;
}
}
标签:des http ar on ad ef as tt new
原文地址:http://www.cnblogs.com/sxmny/p/4137899.html