我试图显示API https://api.battlemetrics.com/servers/20151421中的MaxPlayers,但结果为0,并且我应该得到200,因为API中的MaxPlayers=200.
请告诉我我做错了什么.
<button @onclick="FetchData">lets go</button>
@if (todo != null)
{
<p>maxPlayers: @todo.maxPlayers </p>
}
@code
{
public Attributes todo;
public HttpClient httpClient = new HttpClient();
public async Task FetchData()
{
todo = await httpClient.GetFromJsonAsync<Attributes>("https://api.battlemetrics.com/servers/20151421");
}
public class Attributes
{
public string id { get; set; }
public string name { get; set; }
public string address { get; set; }
public string ip { get; set; }
public int port { get; set; }
public int players { get; set; }
public int maxPlayers { get; set; } // <-- this
public int rank { get; set; }
public List<double> location { get; set; }
public string status { get; set; }
public Details details { get; set; }
public bool @private { get; set; }
public DateTime createdAt { get; set; }
public DateTime updatedAt { get; set; }
public int portQuery { get; set; }
public string country { get; set; }
public string queryStatus { get; set; }
}