1、需要引用
using System.Web.Script.Serialization;
2、采用方法如下:
List<Student> lists = new List<Student> {
new Student{ Name ="小李", Gender ="男"},
new Student{ Name ="小王", Gender="男"}
};
context.Response.Write( new JavaScriptSerializer().Serialize(lists));