ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل Kashif Akhter , VP - Wing Head Application Development , National Bank of Pakistan
تاريخ النشر: 2013/04/21
Zaid Rabab'a
من قبل Zaid Rabab'a , Technical Team Lead , ESKADENIA Software

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

Murad Bin Makhashin
من قبل 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 :)

المزيد من الأسئلة المماثلة