public async static Task <StopsJSON.Rootobject> ExecuteQuery() { StopsJSON.Rootobject ro; HttpClient client = new HttpClient(); string url = baseURL + queryFilter; // Execute the REST API call. // HttpResponseMessage response = await client.GetAsync(baseURL + queryFilter); HttpResponseMessage response = await client.GetAsync(url); // Get the JSON response. string contentString = await response.Content.ReadAsStringAsync(); // Instantiate return object try { JsonTextReader reader = new JsonTextReader(new StringReader(contentString)); JsonSerializer serializer = new JsonSerializer(); ro = (StopsJSON.Rootobject)serializer.Deserialize(reader, typeof(StopsJSON.Rootobject)); return(ro); } catch (Exception ex) { //retval.Add("Exception: " + ex.ToString()); return(ro = new StopsJSON.Rootobject()); } }
public static List <Stop> convertJSONToList(StopsJSON.Rootobject ro) { List <Stop> newList = new List <Stop>(); Stop newStop; foreach (StopsJSON.Datum d in ro.data) { newStop = new Stop(d.id, d.attributes.name, d.attributes.description, d.attributes.latitude, d.attributes.longitude, d.relationships.parent_station.data == null? "" : d.relationships.parent_station.data.id, d.relationships.parent_station.data == null ? "" : d.relationships.parent_station.data.type, d.attributes.wheelchair_boarding); newList.Add(newStop); } return(newList); }