Untitled
unknown
csharp
3 years ago
2.6 kB
8
Indexable
using System;
using RestSharp;
using Newtonsoft.Json;
class Program
{
static void Main()
{
const string url = "https://db.ygoprodeck.com/api/v7/cardinfo.php";
var client = new RestClient(url);
var response = client.Execute(new RestRequest());
var Cards = JsonConvert.DeserializeObject<List<Datum>>(response.Content); // Json array error?
// do stuff with card list
}
}
public class CardImage
{
[JsonProperty("id")]
public int id { get; set; }
[JsonProperty("image_url")]
public string image_url { get; set; }
[JsonProperty("image_url_small")]
public string image_url_small { get; set; }
}
public class CardPrice
{
[JsonProperty("cardmarket_price")]
public string cardmarket_price { get; set; }
[JsonProperty("tcgplayer_price")]
public string tcgplayer_price { get; set; }
[JsonProperty("ebay_price")]
public string ebay_price { get; set; }
[JsonProperty("amazon_price")]
public string amazon_price { get; set; }
[JsonProperty("coolstuffinc_price")]
public string coolstuffinc_price { get; set; }
}
public class CardSet
{
[JsonProperty("set_name")]
public string set_name { get; set; }
[JsonProperty("set_code")]
public string set_code { get; set; }
[JsonProperty("set_rarity")]
public string set_rarity { get; set; }
[JsonProperty("set_rarity_code")]
public string set_rarity_code { get; set; }
[JsonProperty("set_price")]
public string set_price { get; set; }
}
public class Datum
{
[JsonProperty("id")]
public int id { get; set; }
[JsonProperty("name")]
public string name { get; set; }
[JsonProperty("type")]
public string type { get; set; }
[JsonProperty("desc")]
public string desc { get; set; }
[JsonProperty("atk")]
public int atk { get; set; }
[JsonProperty("def")]
public int def { get; set; }
[JsonProperty("level")]
public int level { get; set; }
[JsonProperty("race")]
public string race { get; set; }
[JsonProperty("attribute")]
public string attribute { get; set; }
[JsonProperty("card_sets")]
public List<CardSet> card_sets { get; set; }
[JsonProperty("card_images")]
public List<CardImage> card_images { get; set; }
[JsonProperty("card_prices")]
public List<CardPrice> card_prices { get; set; }
}
public class Root
{
[JsonProperty("data")]
public List<Datum> data { get; set; }
}Editor is loading...