Looks for information on how to parse this json, however everything I tried failed.
I am trying to parse JSON with this code:
var client = new WebClient();
client.Headers.Add("User-Agent", "Nobody");
var response = client.DownloadString(new Uri("https://api.worldoftanks.ru/wot/encyclopedia/tanks/?application_id=demo"));
Response asd = JsonConvert.DeserializeObject<Response>(response);
And I also have this class setting in another file:
public class Response
{
public string status { get; set; }
public int count { get; set; }
public List<Tank> data { get; set; }
}
public class Tank
{
public string nation_i18n { get; set; }
public string name { get; set; }
public int level { get; set; }
public string image { get; set; }
public string image_small { get; set; }
public string nation { get; set; }
public bool is_premium { get; set; }
public string type_i18n { get; set; }
public string contour_image { get; set; }
public string short_name_i18n { get; set; }
public string name_i18n { get; set; }
public string type { get; set; }
public int tank_id { get; set; }
}
They are identical to the data returned by the URL (please open it and you will see how it is built)
One thing that I think is wrong is that with the “data” tag of the answer, instead of having the “Tank” tag for each tank, they actually called it individual identifiers. (again, please refer to the url)
Can someone help me with this? At the moment, I am getting the error:
"Newtonsoft.Json.JsonSerializationException" Newtonsoft.Json.dll : JSON (, { "name": "value" }) 'System.Collections.Generic.List`1 [WotApp.Classes.Tank]', , JSON- (, [1,2,3]). , JSON JSON (, [1,2,3]), , .NET. type (, integer, ), JSON. JsonObjectAttribute , JSON. Path 'data.1', 1, 39.
. : (