En ocasiones nos interesa serializar un objeto en JSON, como por ejemplo al usar el AJAX de jQuery. Es tan fácil como esto:
static public string ToJSON(object obj)
{
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
return serializer.Serialize(obj);
}
I have to say that for the past few of hours i have been hooked by the amazing posts on this site. Keep up the wonderful work.