1

How to get the json data from url using xamarin cross platform development.

Satheesh Natarajan
  • 459
  • 2
  • 7
  • 31

1 Answers1

1
private const string Url = "http://www.nactem.ac.uk/software/acromine/dictionary.py?sf={0}";
public async Task<List<RootObject>> GetResult(string SearchString)
{
    try
    {
        var client = new HttpClient();
        var json = await client.GetStringAsync(string.Format(Url, SearchString));
        return JsonConvert.DeserializeObject<List<RootObject>>(json.ToString());
    }
    catch (System.Exception exception)
    {
        return null;
    }
}

using HttpClient call url and getStrinAsyncc to get string from the url. using DeserializeObject to convert the string into json format. For refer more click here to see complete program in xamarin

valdetero
  • 4,624
  • 1
  • 31
  • 46
Satheesh Natarajan
  • 459
  • 2
  • 7
  • 31