c# - JsonCovert.DeserializeObject<T> is loading the object type but none of the Json Fields -


i new coding in c# , serializing json objects.

i trying use json.net load in file saved json object ("filename.json")

below code trying use load in. have looked around here on best way load in json object , appears consensus. object trying load in defined later in class. used http://json2csharp.com/ tool create class json file.

list<dashboardlist> dashboardlist = null;         dashboardlist db = new dashboardlist();         try         {             streamreader sr = new streamreader(fileloc);             string jsonstring = sr.readtoend();             db = jsonconvert.deserializeobject<dashboardlist>(jsonstring); 

the json object follows.

{   "dashboardlist": { "dashboard": {   "id": "1",   "title": "executive dashboard",   "description": "generic dashboard",   "allowablemembertypes": "",   "pages": {     "page": [ 

the rest of json long , not important.

when run code dashboard object null fields.

edit:

 public class dashboard     {         public string id { get; set; }         public string title { get; set; }         public string description { get; set; }         public string allowablemembertypes { get; set; }         public pages pages { get; set; }     }      public class dashboardlist     {         public dashboard dashboard { get; set; }     }     

for posterity:

        rootobject ro = new rootobject();          try         {              streamreader sr = new streamreader(fileloc);             string jsonstring = sr.readtoend();             javascriptserializer ser = new javascriptserializer();             ro = ser.deserialize<rootobject>(jsonstring);          } 

you need add reference system.web.extensions in .net 4.0 in program files (x86) > reference assemblies> framework> system.web.extensions.dll , need sure you're using regular 4.0 framework not 4.0 client


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

mysql - Pass value between different pages (form) with PHP -