I'm serializing a multi-level json object. These are called webinars and each contain information like below. I can access the first level with no problems. I can access the 2nd level (categories >) if I do so like webinars[webinar].categories.TimeZone etc but I can't loop through it. When I try to foreach(category in webinar) {} I get:
CS1579 C# foreach statement cannot operate on variables of type because does not contain a public definition for 'GetEnumerator'
What have I done wrong?
thanks for your help.
SAMPLE JSON
{
"date": "2017-11-08T02:33:57Z",
"title": "Craft, The",
"desc": "Galeazzi's fx l rad, subs for opn fx type 3A/B/C w malunion",
"startTime": "4:03 AM",
"endTime": "5:46 PM",
"categories": {
"category": "e-learning",
"timeZone": "Asia/Jakarta",
"language": "English"
}
}
Model
public class Rootobject
{
public Webinar[] Webinars { get; set; }
public ELearning[] Elearning { get; set; }
}
public class Webinar
{
public DateTime Date { get; set; }
public string Title { get; set; }
public string Desc { get; set; }
public string StartTime { get; set; }
public string EndTime { get; set; }
public WebinarCategories Categories { get; set; }
}
public class WebinarCategories
{
public string Category { get; set; }
public string TimeZone { get; set; }
public string Language { get; set; }
}
What I'm trying to achieve
foreach (var webinar in root.webinars) {
foreach (var category in webinar) {
<button href="javascript:void(0)" class="dropbtn">@category</button>
}
}