public void get_json2() { queryUrl = apiUrl; queryUrl += "client_id=" + clientID; queryUrl += "&client_secret=" + clientSecret; queryUrl += "&v=" + String.Format("{0:yyyyMMdd}", DateTime.Now); queryUrl += "&ll=" + latitude + "," + longitude; queryUrl += "&radius=" + radius.ToString(); queryUrl += "&categoryId=" + foodCode; string jsonString = string.Empty; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(queryUrl); request.AutomaticDecompression = DecompressionMethods.GZip; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (Stream stream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(stream)) { jsonString = reader.ReadToEnd(); } FoursquareModel returnValue = JsonConvert.DeserializeObject <FoursquareModel>(jsonString); list = returnValue.response.venues.OrderBy(x => x.location.distance); }
public async void get_json() { queryUrl = apiUrl; queryUrl += "client_id=" + clientID; queryUrl += "&client_secret=" + clientSecret; queryUrl += "&v=" + String.Format("{0:yyyyMMdd}", DateTime.Now); queryUrl += "&ll=" + latitude + "," + longitude; queryUrl += "&radius=" + radius.ToString(); queryUrl += "&categoryId=" + foodCode; HttpClient client = new HttpClient(); string jsonString = null; try { jsonString = await client.GetStringAsync(queryUrl); } catch (Exception exp) { } if (jsonString != null) { FoursquareModel returnValue = JsonConvert.DeserializeObject <FoursquareModel>(jsonString); list = returnValue.response.venues.OrderBy(x => x.location.distance); } //icon_url = list.ElementAt(0).categories[0].icon.prefix + "100" + list.ElementAt(0).categories[0].icon.suffix; }