public static List <Game> GetGames(string apiKey) { var apiCallTask = ApiCallHelper.GameApiCall(apiKey); var result = apiCallTask.Result; JObject jsonResponse = JsonConvert.DeserializeObject <JObject>(result); List <Game> gameList = JsonConvert.DeserializeObject <List <Game> >(jsonResponse["games"].ToString()); return(gameList); }
public static List <Result> GetResults(string key, string searchTerm) { var apiCallTask = ApiCallHelper.PlacesApiCall(key, searchTerm); var result = apiCallTask.Result; Console.WriteLine(">>>>>>>>>>>>>" + result); JObject jsonResponse = JsonConvert.DeserializeObject <JObject>(result); var results = jsonResponse["searchResults"].Children().ToList(); List <Result> resultList = new List <Result>(); foreach (var resultItem in results) { JObject jtok = JsonConvert.DeserializeObject <JObject>(resultItem.ToString()); Result rItem = JsonConvert.DeserializeObject <Result>(jtok["fields"].ToString()); resultList.Add(rItem); } // List<Result> resultList = JsonConvert.DeserializeObject<List<Result>>(jsonResponse["searchResults/fields"].ToString()); return(resultList); }