Newtonsoft.Json.dll 或者通过-》工具-》库程序包管理工具-》NuGet管理包-》联机 输入Newtonsoft或者json.net
Newtonsoft.Json是可以的:
context.Response.ContentType = "text/plain";
BooksService service = new BooksService();
List<Books> list=service.GetAll().Take(5).ToList();
JsonSerializerSettings setting = new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};
strintret = JsonConvert.SerializeObject(list, setting);
context.Response.Write(ret);