I am parsing the following JSON:
{
result: [
{
EventType: {
EventTypeDesc: "horse-racing",
events: {
Local: {
Events: {
530857: {
Venue: "Northam",
StateCode: "WA",
CountryCode: "AUS"
},
530858: {
Venue: "Caulfield",
StateCode: "VIC",
CountryCode: "AUS"
}
}
}
}
}
}
]
}
I can access the element through following code:
responseDeserializeObject.result[0].EventType.events.Local.Events["530857"].Venue
However, the following C# code doesn't work:
dynamic responseDeserializeObject = HttpGetResponse(endPoint);
foreach (var event in responseDeserializeObject.result[0].EventType.events.Local.Events)
{
Console.WriteLine(event.Venue);
Console.WriteLine(event.StateCode);
Console.WriteLine(event.CountryCode);
}
Any help will be highly appreciated.
Console.Writeline(..)