我试图反序列化我的JSON并将值输出到UITableViewCell。看起来它永远不会碰到我的foreach循环。我放了一个断点,它从来没有击中它,我的loadingIndicator继续旋转。
我的JSON看起来像这样:"theYear":"2012","theMake":"Chevrolet/GMC","theModel":"Avalanche 1500 4WD","theEngine":"5.3L V-8","theTowLimit":"5000","notes":"3.08 axle ratio "
代码:
string result = await content.ReadAsStringAsync ();
var parsed = JsonConvert.DeserializeObject<TowInfo> (result);
//theTopInfo.Text = parsed.theYear + " " + parsed.theMake + " " + parsed.theModel;
foreach (var item in parsed.data) {
Console.WriteLine(item.theEngine + " " + item.theTowLimit + " " + item.notes);
}
public class TowInfo
{
public List<TowRatings> data { get; set;}
}
public class TowRatings
{
public string theYear { get; set; }
public string theMake { get; set; }
public string theModel { get; set; }
public string theEngine { get; set; }
public string theTowLimit { get; set; }
public string notes { get; set; }
}