星空网 > 软件开发 > ASP.net

Json序列化为对象方法

 /// <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);
}




原标题:Json序列化为对象方法

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

越南胡志明国际货运:https://www.goluckyvip.com/tag/104791.html
越南出口货运:https://www.goluckyvip.com/tag/104792.html
越南物流专线找哪家:https://www.goluckyvip.com/tag/104793.html
中国到越南物流费用价格表:https://www.goluckyvip.com/tag/104794.html
给越南专线物流哪家好:https://www.goluckyvip.com/tag/104796.html
广东到越南货运:https://www.goluckyvip.com/tag/104797.html
百崖大峡谷生态旅游景区(探秘中国西南自然风光):https://www.vstour.cn/a/363176.html
海陵岛马尾岛景点介绍 海陵马尾岛图片:https://www.vstour.cn/a/363177.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流