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 is always returning as NULL and the CaseModel details are not being populated. The JSON string obviously has data, but I feel that my class structure is somehow messed up with the root level class. It appears similar to other examples posted here and elsewhere, so I’m at a loss right now. Any help is greatly appreciated.
If you modify your JSON string to
then it should work.
Properties of JSON object correspond to the properties of .NET object having the same name.