JSON Serialization in AJAX.net both Client side and Server side

Published Tuesday, April 14, 2009 6:34 AM

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<yourCustomType>(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

# DotNetKicks.com said on Tuesday, April 14, 2009 6:39 AM

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

# Amr ElGarhy » Shared Items - April 14, 2009 said on Tuesday, April 14, 2009 3:16 PM

Pingback from  Amr ElGarhy &raquo; Shared Items - April 14, 2009

Leave a Comment

(required) 
(required) 
(optional)
(required)