c# - How to convert a complex JSON in JS into a .NET class in Silverlight -


i have silverlight project has interoperate current javascript library json data using ajax , json data looks following:

{"javaclass":"java.util.arraylist","list":[{"job_num":"21", "deadline":{"time":1359583200000,"javaclass":"java.sql.timestamp"}, "javaclass":"jobentity"}]} 

in silverlight, i've created "bridge" class convert json data c# classes. , main method follows:

public static t invoke<t>(string method)     {         scriptobject result = htmlpage.window.eval("$.parsejson("+method+")") scriptobject;         if (result != null)         {             scriptobject data = result.getproperty("list") scriptobject;             if (data != null)                 return data.convertto<t>();         }          return default(t);     } 

also, attach entity poco class (simplified) here.

public class jobentity {     public string job_num {get; set;}     public string deadline {get; set;} } 

the question how convert timestamp named "deadline" date formatted string in c#. guess might related setter accessor in property of deadline.

by way fount weird can't use scriptobject's convertto<string>() method if evaluated value string in javascript. namely, can parse string in way:

scriptobject.tostring();  //convertto<string>() not work. 

what's point here?

any appreciated.

using newtonsoft.json assembly can parse json string jtoken object find date property, accepted answer question deserializing json .net object using newtonsoft (or linq json maybe?)


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -