public TrafficInformation ParseTrafficInfoListResponse(string jsonResponse)
{
var rootObj = JsonConvert.DeserializeObject<TILP.RootObject>(jsonResponse);
if (null == rootObj || null == rootObj.data)
{
return new TrafficInformation();
}
// There is no traffic information at all (i.e. no alerts)
if (null == rootObj.data.trafficInfos)
{
return new TrafficInformation(succeeded: true);
}
var items = new List<TrafficInformationItem>();
foreach (var ti in rootObj.data.trafficInfos)
{
var item = new TrafficInformationItem()
{
Title = ti.title,
Description = ti.description,
RelatedLines = String.Join(", ", ti.relatedLines),
Start = ToLocalTime(ti.time.start),
End = ToLocalTime(ti.time.end)
};
items.Add(item);
}
if (items.Any())
return new TrafficInformation(items);
return new TrafficInformation(succeeded: true);
}