[C#] C# object Serialize to Json

摘要:[C#] C# object Serialize to Json

JavaScriptSerializer TheSerializer = new JavaScriptSerializer();
 
List<object> list = new List<object>();
 
list = new List<object>() {
new  { Value = "1", Text = "活動內容一" },
new  { Value = "2", Text = "活動內容二"},
new  { Value = "3", Text = "活動內容三"},
new  { Value = "4", Text = "活動內容四"}
};
 
var thesjon = TheSerializer.Serialize(list);

var thesjon = JsonConvert.SerializeObject(list);  // 也可以使用json.net來序列化