Well, I'm new to programming, and I have a problem.
This is my class Valores
public class Valores
{
[JsonProperty("nome")]
public string Nome { get; set; }
[JsonProperty("valor")]
public double Valor { get; set; }
[JsonProperty("ultima_consulta")]
public int UltimaConsulta { get; set; }
[JsonProperty("fonte")]
public string Fonte { get; set; }
}
And this is my method where I get and deserialize my Json
public static async Task<Valores> GetAsync()
{
Valores valores = null;
using (var client = new HttpClient())
{
var json = await client.GetStringAsync("http://api.promasters.net.br/cotacao/v1/valores");
valores = JsonConvert.DeserializeObject<Valores>(json);
}
return valores;
}
This is json that the way: "http://api.promasters.net.br/cotacao/v1/valores" returns.
{
"status": true,
"valores": {
"USD": {
"nome": "Dólar",
"valor": 3.0717,
"ultima_consulta": 1490040302,
"fonte": "UOL Economia - http://economia.uol.com.br/"
},
"EUR": {
"nome": "Euro",
"valor": 3.3002,
"ultima_consulta": 1490040302,
"fonte": "UOL Economia - http://economia.uol.com.br/"
},
"ARS": {
"nome": "Peso Argentino",
"valor": 0.1965,
"ultima_consulta": 1490040302,
"fonte": "UOL Economia - http://economia.uol.com.br/"
},
"GBP": {
"nome": "Libra Esterlina",
"valor": 3.7966,
"ultima_consulta": 1490040302,
"fonte": "UOL Economia - http://economia.uol.com.br/"
},
"BTC": {
"nome": "Bitcoin",
"valor": 3472,
"ultima_consulta": 1490067603,
"fonte": "Mercado Bitcoin - http://www.mercadobitcoin.com.br/"
}
}
}
I do not know what I did wrong, because this
var json = await client.GetStringAsync("http://api.promasters.net.br/cotacao/v1/valores");
It was to receive Json in string, but is not receiving anything, it's like an empty string.