Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'System.Collections.Generic.List`
JArray jsonResponse = JArray.Parse(goldString);
foreach (var item in jsonResponse)
{
JObject jRaces = (JObject)item["races"];
foreach (var rItem in jRaces)
{
string rItemKey = rItem.Key;
JObject rItemValueJson = (JObject)rItem.Value;
Races rowsResult = Newtonsoft.Json.JsonConvert.DeserializeObject<Races>(rItemValueJson.ToString());
}
}
Could try with:
JArray jsonResponse = JArray.Parse(goldString);
foreach (var item in jsonResponse)
{
foreach (var rItem in jRaces)
{
string rItemKey = rItem.Key;
JObject rItemValueJson = (JObject)rItem.Value;
Races rowsResult = item.Value<JObject>("races").ToObject<Races>();
}
}