I have a JSON file which I want to deserialize. I am very new to JSON and Deserialization in general and have found this quite challenging . My JSON file structure is as follows ,
{
"SchoolName": "ThisIsTheSchoolName",
"Student": [
{
"Id": "s001",
"Name": "ABC"
},
{
"Id": "s002",
"Name": "CDE"
},
{
"Id": "s003",
"Name": "EFG"
},
{
"Id": "s004",
"Name": "GHI"
},
{
"Id": "s005",
"Name": "IJK"
}
]
}
What I am trying to do is first store the "SchoolName" as a variable ( Which I will need later on in my application) . Secondly I want to iterate through the JSON list "Student" and store every value in "Id" in a List and Every Value in "Name" in another List . I was not able to fathom a way to do this . Here is what I have been able to try so far (Which )
string filePath = @"D:\Projects\Student.json";
string data = File.ReadAllText(filePath);
Console.Write(data);
Console.ReadLine();
dynamic stuList= JsonConvert.DeserializeObject(data);
foreach (var item in stuList)
{
//string Id = item.Id;
//string Name= item.Version;
}
Would really appreciate some help or direction to something that I can get a head start on this