// declare a method within that which converts the string to data. This will be unique for this website, hence why I’ve put that in the name. // you’ll have to make a new method like this for each api you want to call. public List <Event> GetdistanceinfoJSONstring(String originalJsonData) { List <Event> events = new List <Event>(); // this line is using the Json.Net classes to convert to a list of Strings GoogleApiStructure google = JsonConvert.DeserializeObject <GoogleApiStructure>(originalJsonData); foreach (Row row in google.rows) { foreach (Element element in row.elements) { events.Add(this.BuildEvent(element)); } } return(events); }
internal string extractFriendlyTimeTakenFromGoogleMapsJsonString(string jsonString) { // this line is using the Json.Net classes to convert to a list of Strings GoogleApiStructure google = JsonConvert.DeserializeObject <GoogleApiStructure>(jsonString); string result = FixtureRetriever.WHEN_NO_VALUE; foreach (Row row in google.rows) { foreach (Element element in row.elements) { // should only be one! if (element.duration != null) { result = Convert.ToString(element.duration["text"]); } } } return(result); }
internal int extractTimeTakenFromGoogleMapsJsonString(string jsonString) { // this line is using the Json.Net classes to convert to a list of Strings GoogleApiStructure google = JsonConvert.DeserializeObject <GoogleApiStructure>(jsonString); int result = FixtureRetriever.SLIGHTLY_SMALLER_BIG_NUMBER; foreach (Row row in google.rows) { foreach (Element element in row.elements) { // should only be one! if (element.duration != null) { result = Convert.ToInt32(element.duration["value"]); } } } return(result); }