Я пытаюсь получить доступ к отдельным тегам из Json Web API. если вы посмотрите на мою Debug сообщение, которое вы можете увидеть, что каждый тег отображается с правильными данными в «jsonMessage», но когда я возвращать «результат» каждый тег устанавливается в нуль:C# - Позвонить в JSON Web API и получить данные
Так как я получить все теги из jsonMessage
вернуться, так что я могу просто ввести, например texblock.text = card.name;
и так далее
public async static Task<Card> GetCard()
{
string url = String.Format("https://api.magicthegathering.io/v1/cards/386616");
HttpClient client = new HttpClient();
//client.BaseAddress = new Uri(url);
var response = await client.GetAsync(url);
var jsonMessage = await response.Content.ReadAsStringAsync();
var serializer = new DataContractJsonSerializer(typeof(Card));
var ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonMessage));
var result = (Card)serializer.ReadObject(ms);
return result;
}
Вот класс карты:
public class Card
{
public string name { get; set; }
public string manaCost { get; set; }
public int cmc { get; set; }
public List<string> colors { get; set; }
public string type { get; set; }
public List<string> types { get; set; }
public List<string> subtypes { get; set; }
public string rarity { get; set; }
public string set { get; set; }
public string text { get; set; }
public string artist { get; set; }
public string number { get; set; }
public string power { get; set; }
public string toughness { get; set; }
public string layout { get; set; }
public int multiverseid { get; set; }
public string imageUrl { get; set; }
public List<Ruling> rulings { get; set; }
public List<ForeignName> foreignNames { get; set; }
public List<string> printings { get; set; }
public string originalText { get; set; }
public string originalType { get; set; }
public List<Legality> legalities { get; set; }
public string id { get; set; }
}