I have json that is posted from a HTTP req. I am trying to deserialize it for use in a for each loop. Unfortunately, its format is kicking my ass as its a list of objects (i believe).
so far i have the following:
dynamic jsonObj = JsonConvert.DeserializeObject(await req.ReadAsStringAsync());
foreach (var p in jsonObj.hireSchedules)
{
///do something
}
My json is as below:
{
"hireSchedules": [
{
"plant": "7246054",
"num" : "79",
"hire": "1137277"
},
{
"plant": "7246055",
"num" : "80",
"hire": "1137278"
}
]
}
I have the following classes:
public class HireSchedule
{
public string plant { get; set; }
public string num { get; set; }
public string hire { get; set; }
}
public class RootObject
{
public List<HireSchedule> hireSchedules { get; set; }
}
Any help would be appreciated. Thanks!
RootObject jsonObj = JsonConvert.DeserializeObject<RootObject>(await req.ReadAsStringAsync());?