only My site

Tuesday, August 30, 2011

JSON & .NET

using System.Web.Script;

Employee oEmployee1 = new Employee { Name = "Pini", ID = "111", Age = "30" };
Employee oEmployee2 = new Employee { Name = "Yaniv", ID = "Cohen", Age = "31" };
Employee oEmployee3 = new Employee { Name = "Yoni", ID = "Biton", Age = "20" };

List oList = new List() { oEmployee1, oEmployee2, oEmployee3 };

Serialization.JavaScriptSerializer serializer = new Serialization.JavaScriptSerializer();

string jsonString = serializer.Serialize(oList);
List oListNew = new List();

oListNew = serializer.Deserialize>(jsonString);
//ser.Deserialize(new StreamReader(response.GetResponseStream()).ReadToEnd());

No comments: