I have a json response that I am trying to deserialize with RestSharp This is how it looks
[{"cname":"APPLICANT NAME","dob":"01-01-1997","gender":"2","msg":"Ok","msgcode":"0"},
{"results":
[{"subjectcode":"214","subject":"SOCIAL STUDIES","grade":"C5"},
{"subjectcode":"302","subject":"ENGLISH LANG","grade":"C5"},
{"subjectcode":"402","subject":"MATHEMATICS(CORE)","grade":"E8"},
{"subjectcode":"517","subject":"INTEGRATED SCIENCE","grade":"D7"},
{"subjectcode":"203","subject":"ECONOMICS","grade":"D7"},
{"subjectcode":"204","subject":"GEOGRAPHY","grade":"B3"},
{"subjectcode":"205","subject":"GOVERNMENT","grade":"C6"},
{"subjectcode":"207","subject":"HISTORY","grade":"B3"}]
}]
I have created these classes to help me serialize
public class Result
{
public string subjectcode { get; set; }
public string subject { get; set; }
public string grade { get; set; }
}
public class StudentDetail
{
public string cname { get; set; }
public string dob { get; set; }
public string gender { get; set; }
public string msg { get; set; }
public string msgcode { get; set; }
public List<Result> results { get; set; }
}
public class VerifyData
{
public List<StudentDetail> StudentDetails { get; set; }
}
However whenever I try to deserialize with RestSharp
IRestResponse response = client.Execute<VerifyData>(request);
I get the following error message:
{"Unable to cast object of type 'RestSharp.JsonArray' to type 'System.Collections.Generic.IDictionary`2[System.String,System.Object]'."}
Any pointers, have searched similar questions but was not able to fix this. Thanks
Json data now is
[{"cname":"APPLICANT NAME","dob":"01-01-1997","gender":"2","msg":"Ok","msgcode":"0",
"results":
[{"subjectcode":"214","subject":"SOCIAL STUDIES","grade":"C5"},
{"subjectcode":"302","subject":"ENGLISH LANG","grade":"C5"},
{"subjectcode":"402","subject":"MATHEMATICS(CORE)","grade":"E8"},
{"subjectcode":"517","subject":"INTEGRATED SCIENCE","grade":"D7"},
{"subjectcode":"203","subject":"ECONOMICS","grade":"D7"},
{"subjectcode":"204","subject":"GEOGRAPHY","grade":"B3"},
{"subjectcode":"205","subject":"GOVERNMENT","grade":"C6"},
{"subjectcode":"207","subject":"HISTORY","grade":"B3"}]
}]