C# JSON转为字符串


//Deserialize<T>(String)   将JSON字符串转化为类型T。

JavaScriptSerializer jss = new JavaScriptSerializer(); IList<IDictionary<string, string>> remarkContent = jss.Deserialize<IList<IDictionary<string, string>>>("字符串"); remarkContent = remarkContent == null ? new List<IDictionary<string, string>>() : remarkContent; IDictionary<string, string> _contentlist = new Dictionary<string, string>();


//向集合添加新的数据

_contentlist["Remark"] = Remark; _contentlist["CreateDate"] = timenow.ToString(); _contentlist["CreateBy"] = username; remarkContent.Add(_contentlist);

 

//转为字符串

remarkList = jss.Serialize(remarkContent);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM