am using NewtonSoft to parse a JSON Api call.
The code must remain in the same format it is in.
My only problem is that I cannot iterate through the values of the JSON in a foreach loop.
How can I solve this problem?
public async Task callWebApi()
{
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://www.metaweather.com/api/location/search/?lattlong=50.068,-5.316"))
{
var response = await httpClient.SendAsync(request);
using (HttpContent content = response.Content)
{
var jsonString = await response.Content.ReadAsStringAsync();
var data = JsonConvert.DeserializeObject<Object>(jsonString);
Console.WriteLine("I need to parse distance, title, location_type, woeid,latt_long so that I can iterate through it using a foreach loop");
Console.WriteLine(data);
Console.Read();
}
}
}
Here is a link to the working code:
What I have tried:
The problem is that I cannot iterate using a foreach loop.