when we send data from server side to client side then data is automatically serialize & converted to json format and jquery can highly parse that json.
as a example
[WebMethod]
public static Person GetData()
{
JavaScriptSerializer js = new JavaScriptSerializer();
Person p1 = new Person();
p1.firstName = "Rakki";
p1.lastName = "Muthukumar";
p1.technologies = new string[] { "IIS", "ASP.NET", "JavaScript", "AJAX" };
return p1;
}
this above trick works and data converted to json format and get back to client then
but i saw people use JavaScriptSerializer class to convert the data in json format and then send the whole json to client side to parse by jquery.
a small sample for JavaScriptSerializer
[WebMethod]
public static string GetData()
{
JavaScriptSerializer js = new JavaScriptSerializer();
Person p1 = new Person();
p1.firstName = "Rakki";
p1.lastName = "Muthukumar";
p1.technologies = new string[] { "IIS", "ASP.NET", "JavaScript", "AJAX" };
string str = js.Serialize(p1);
}
i just need to know why people use JavaScriptSerializer class to convert data in json format when data is automatically converted to json.
tell me the exact situation when one has to use JavaScriptSerializer to make data converted to json format.
please discuss this in detail....thanks