The JSON you shared above is invalid. The code does not compile and contains a lot of logical errors. Is there anyway you can provide, at the very least, valid JSON?
Below is an example based on you original code. Feel free to modify the code to suite your needs.
JSON
[
{
"PageNo": 1,
"FormId": 98,
"FormType": 1,
"TimeEntryDetails": [
{
"Loc": "loc",
"Set": "set",
"LunchStart": "12:00",
"LunchEnd": "1:00",
"WrapTime": "e",
"Zone": "r"
},
{
"Loc": "loc1",
"Set": "set2",
"LunchStart": "12:00",
"LunchEnd": "1:00",
"WrapTime": "rrr",
"Zone": "kkkk"
}
]
}
]
Model
public class TimeModel
{
public int PageNo { get; set; }
public int FormId { get; set; }
public int FormType { get; set; }
public Timeentrydetail[] TimeEntryDetails { get; set; }
}
public class Timeentrydetail
{
public string Loc { get; set; }
public string Set { get; set; }
public string LunchStart { get; set; }
public string LunchEnd { get; set; }
public string WrapTime { get; set; }
public string Zone { get; set; }
}
Implementation
static async Task Main(string[] args)
{
string fileName = @"C:\Net5Demos\ConsoleAppCS\data.json";
List<TimeModel> results = JsonConvert.DeserializeObject<List<TimeModel>>(File.ReadAllText(fileName));
foreach(TimeModel tm in results)
{
Console.WriteLine(tm.PageNo);
Console.WriteLine(tm.FormId);
Console.WriteLine(tm.FormType);
foreach(Timeentrydetail detail in tm.TimeEntryDetails)
{
Console.WriteLine($"\t{detail.Loc}");
Console.WriteLine($"\t{detail.Set}");
Console.WriteLine($"\t{detail.LunchStart}");
Console.WriteLine($"\t{detail.LunchEnd}");
Console.WriteLine($"\t{detail.WrapTime}");
Console.WriteLine($"\t{detail.Zone}");
Console.WriteLine($"-----------------");
}
}
}