asp.net mvc - Cosuming JSON with JavaScriptSerializer returns NULL object -
my json string:
jsonstring ="{"getstatusresult":[{"casecompleteind":"n","casenbr":"999999","insurgerynowind":"y","inroomnowind":"n"}]}"; my classes:
public class getstatusresult { public list<casemodel> casedetails { get; set; } } public class casemodel { public string casecompleteind { get; set; } public string caseconfirmnbr { get; set; } public string insurgerynowind { get; set; } public string inroomnowind{ get; set; } } }
my code:
getstatusresult caseinfo = new getstatusresult(); javascriptserializer jsserializer = new javascriptserializer(); caseinfo = jsserializer.deserialize<getstatusresult>(jsonstring); my problem:
the object returning null , casemodel details not being populated. json string has data, feel class structure somehow messed root level class. appears similar other examples posted here , elsewhere, i'm @ loss right now. appreciated.
if modify json string to
jsonstring ="{"casedetails":[{"casecompleteind":"n","casenbr":"999999","insurgerynowind":"y","inroomnowind":"n"}]}"; then should work.
properties of json object correspond properties of .net object having same name.
Comments
Post a Comment