chamila99 Perera chamila99 Perera - 6 months ago 23
JSON Question

Deserialize Json Using NewtonJS

I have WCF Rest service Returns Json , I Get the response Json string but after De-serializing It gives Null object ,Json contains response object which contains List , before De-serializing string json string shows 3 DTOStundet objects after De-serializing List shows null

string returnValue = Navigator.GET(url, APIHearderCollection);

"CourseName":"Physical Sience",
"StudentId":1,"StudentName":"Kumar Sangakkara",
"Age":21,"CourseName":"Physical Sience",
"StudentId":2,"StudentName":"Mahela Jayawardena",

returnValue contain this json string to be De-serialize

image description here]1

this is where im De-serializing json after this response gets null

Response response = (Response)Newtonsoft.Json.JsonConvert.DeserializeObject(returnValue, typeof(Response));


You can deserialize this way, create separate model class

public class NewModel
    public Response GetStudentsListJSONResult { get; set; };

public class NewModel2
    public NewModel Result { get; set; };


NewModel2 response = Newtonsoft.Json.JsonConvert.DeserializeObject<NewModel2>(returnValue);