Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How to deserialize the object with javaScript deserializer in ScriptEnabled Service call?

user-image
Question ajoutée par Kashif Akhter , VP - Wing Head Application Development , National Bank of Pakistan
Date de publication: 2013/04/21
Zaid Rabab'a
par Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.

make josn obj using system.web.script.serialization.javascriptserializer();

Murad Bin Makhashin
par Murad Bin Makhashin , Software Developer , Dar Al Tamleek

To serialize an object to JSON string, you need to use the method System.Web.Script.Serialization.JavaScriptSerializer.Serialize, and pass your object as an argument.
Here is an example (note: in console application project, you might want to add a reference to System.Web): public class Person { public string Name {get; set;} public int Age {get; set;} public List Contacts {get; set;} } public class Program { static void Main(string[] args){ Person p = new Person { Name = "Whoever", Age = 30, Contacts = new List() } p.Contacts.Add("Contact 1"); p.Contacts.Add("Contact 2"); p.Contacts.Add("Contact 3"); var json = new System.Web.Script.Serialization.JavaScriptSerializer() .Serialize(p); Console.WriteLine(json); } } Hope that helps :)

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?