C# 中将json字符串转化成List<obj>

在程序集中添加引用 System.Web.Extensions

在类中添加引用

using System.Runtime.Serialization;
using System.Web.Script.Serialization;

JavaScriptSerializer Serializer = new JavaScriptSerializer();

List mouldNameList = Serializer.Deserialize>(GetMouldName().ToString());
//kendo select的數據源格式
public class DropDownBasicData
{
       public string DropDownId { get; set; }
       public string DropDownValue { get; set; }
       public string DropDownText { get; set; }
}
//序列化:List 转 json字符串
Newtonsoft.Json.JsonConvert.SerializeObject(result); 

//反序列化:json字符串 转 List
JavaScriptSerializer Serializer = new JavaScriptSerializer();
List mouldNameList = Newtonsoft.Json.JsonConvert.DeserializeObject>(GetMouldNameToStr());

你可能感兴趣的:(C#,json字符串转List,序列化与反序列化)