generic list into a JSON string

using System.Runtime.Serialization.Json;

List<Person> myResults = GetNames(searchFor);
           JavaScriptSerializer jes = new JavaScriptSerializer();
           string jsonResults = jes.Serialize(myResults);
          //return as JSON result
          context.Response.ContentType = "applcation/json";
          context.Response.Write(jsonResults);

Advertisements