/// <summary>
/// json 序列化为对象
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="jsonString">Json对象</param>
/// <returns></returns>
public static T JsonDeserialize<T>(string jsonString)
{
if (jsonString==""||jsonString==null)
{
return default(T);
}
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
T obj = (T)ser.ReadObject(ms);
return obj;
}

实用例子

context.Response.ContentType = "text/plain";
string updated = context.Request["updated"];
List<ShowCCK_DHModle> modelList = null;
if (updated != "")
{
modelList = JsonDeserialize<List<ShowCCK_DHModle>>(updated);
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
猜你喜欢
  • 2021-11-30
  • 2021-08-02
  • 2021-11-24
  • 2022-01-24
相关资源
相似解决方案