Hi yogesjoshi,
Check this example. Now please take its reference and correct your code.
JSON
{
"StudentInfo": [
{
"department": {
"id": "1",
"name": "CS"
},
"name": "abc",
"address": "abcdefg",
"phone": "1234567890",
"merchantLocatorCode": "string"
},
{
"department": {
"id": "1",
"name": "CS"
},
"name": "abc",
"address": "abcdefg",
"phone": "1234567890",
"merchantLocatorCode": "string"
},
{
"department": {
"id": "1",
"name": "CS"
},
"name": "abc",
"address": "abcdefg",
"phone": "1234567890",
"merchantLocatorCode": "string"
}
]
}
Model
public class Students
{
public List<Student> StudentInfo { get; set; }
}
public class Student
{
public Department department { get; set; }
public string name { get; set; }
public string address { get; set; }
public string phone { get; set; }
public string merchantLocatorCode { get; set; }
}
public class Department
{
public string id { get; set; }
public string name { get; set; }
}
Controller
public void LoadJson()
{
Students studentInfo;
using (StreamReader r = new StreamReader(@"c:\data\Student.json")))
{
var json = r.ReadToEnd();
studentInfo = JsonConvert.DeserializeObject<Students>(json);
}
}
Screenshot