MD Sayem Ahmed
MD Sayem Ahmed

Reputation: 29176

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 the 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 ?

Upvotes: 2

Views: 2177

Answers (1)

Daniel Lee
Daniel Lee

Reputation: 7979

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/

Upvotes: 3

Related Questions