json serialization in ajax net both client side and server side

Tuesday, April 14, 2009 8:34 AM | Leave a reply »

JSON objects representations are small and lightweight compared to XML they are now the core of AJAX.net services serialization. in AJAX.net they work out of the box

you can serilaize/deserialize  your objects to JSON using this snippet of server side code

using System.Web.Script.Serialization;
JavaScriptSerializer jss = new JavaScriptSerializer();
//Serialize
jss.Serialize(object);
//Deserialize
yourCustomType result = jss.Deserialize(yourJSONString);

 

and on the client side you can do the same as long as you have a script manager in your page

// Serialization
var jsonString= Sys.Serialization.JavaScriptSerializer.serialize(JSObject);
//deserialization 
var JSObject= Sys.Serialization.JavaScriptSerializer.deserialize(jsonString);


Comments

  1. Gravatar Anonymous says:

    Re : # 

    You've been kicked (a good thing) - Trackback from DotNetKicks.com


  2. Gravatar Anonymous says:

    Re : # 

    Pingback from  Amr ElGarhy » Shared Items - April 14, 2009


Leave a Reply



 

Please add 4 and 8 and type the answer here: