static SecondLink.RootObject getBeerFromStr2(string link) // al doilea link, adica cel in care se gasesc berile are o structura // diferita de cea a primului link, de aceea avem nevoie de o noua clasa { RootObject obj1 = new RootObject(); string realLink; realLink = "http://datc-rest.azurewebsites.net" + link; hal halObj = new Client.hal(); var client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/hal+json")); var response = client.GetAsync(realLink).Result; var data = response.Content.ReadAsStringAsync().Result; SecondLink.RootObject x = JsonConvert.DeserializeObject <SecondLink.RootObject>(data); // Console.WriteLine(data); return(x); }
static beersInfo.RootObject getBeerInfo(string link) { RootObject obj1 = new RootObject(); string realLink; realLink = "http://datc-rest.azurewebsites.net" + link; hal halObj = new Client.hal(); var client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/hal+json")); var response = client.GetAsync(realLink).Result; var data = response.Content.ReadAsStringAsync().Result; //Console.WriteLine(data); // afisarea json-ului ajuta la determinarea clasei cu ajutorul [email protected] beersInfo.RootObject x = JsonConvert.DeserializeObject <beersInfo.RootObject>(data); // Console.WriteLine(data); return(x); }
static hal.RootObject getBeerFromStr(string link) { RootObject obj1 = new RootObject(); string realLink; realLink = "http://datc-rest.azurewebsites.net" + link; // folosesc in acest stil pentru ca vreau sa pot sa adaug // linkurile fara sa fie nevoie sa fac mai multe functii (pentru json-urile de acelasi tip) hal halObj = new Client.hal(); var client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/hal+json")); var response = client.GetAsync(realLink).Result; var data = response.Content.ReadAsStringAsync().Result; hal.RootObject x = JsonConvert.DeserializeObject <hal.RootObject>(data); //Console.WriteLine(data); return(x); }