http://xurrency.com/api this webservice is returning a json response message. how can I use this message as an object in my .net project (asp.net web app)
You could start by defining the model classes that will handle the response:
public class XurrencyResponse
{
public string Status { get; set; }
public string Code { get; set; }
public string Message { get; set; }
public Result Result { get; set; }
}
public class Result
{
public decimal Value { get; set; }
public string Target { get; set; }
public string Base { get; set; }
public DateTime Updated_At { get; set; }
}
Once you have them you simply call the service:
class Program
{
static void Main()
{
var serializer = new JavaScriptSerializer();
string json = null;
using (var client = new WebClient())
{
json = client.DownloadString("http://xurrency.com/api/eur/gbp/1.5");
}
var response = serializer.Deserialize<XurrencyResponse>(json);
Console.WriteLine(response.Status);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With