How to convert an Object List into JSON in ASP.NET
I have a list of person objects which I want to send in response to a jquery' ajax request. I want to send t开发者_如何学JAVAhe list into JSON format. The list is as follows -
List<Person> PersonList = new List<Person>();
Person X = new Person("X", 23, "This is X");
Person Y = new Person("Y", 24, "This is Y");
PersonList.Add(X);
PersonList.Add(Y);
How can I convert this PersonList
list into JSON ?
JSON.NET has worked really well for me. http://www.codeplex.com/Json
And if you are doing Web Forms and JQuery then this link might help you out:
http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/
精彩评论