Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ui; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import rest.Elevation; import org.springframework.web.client.RestTemplate; import rest.Result; import rest.Weather; import rest.Current; import service.DatabaseFacade; /** * * @author Eline */ public class TestRest { public static void main(String[] args) throws IOException { RestTemplate restTemplate = new RestTemplate(); String response = restTemplate.getForObject( "http://api.apixu.com/v1/current.json?key=aebe5a3f024040ff9bf112640160705&q=Brussel", String.class); //System.out.println(response.getConditions().toString()); System.out.println(response.toString()); //System.out.println(response.toString()); //RestTemplate restTemplate = new RestTemplate(); // ObjectMapper jacksonObjectMapper = new ObjectMapper(); // LinkedHashMap map= restTemplate.getForObject("http://api.apixu.com/v1/current.json?key=aebe5a3f024040ff9bf112640160705&q=Brussel", LinkedHashMap.class); //Weather weatherDescription = jacksonObjectMapper.convertValue(map.get("current"), Weather.class); //String weatherCondition = jacksonObjectMapper.convertValue(map.get("current"), String.class); // Current current = restTemplate.getForObject("http://api.apixu.com/v1/current.json?key=aebe5a3f024040ff9bf112640160705&q=Brussel", Current.class); // DatabaseFacade service = new DatabaseFacade(); // System.out.println(service.getWeather()); // System.out.println(weatherCondition.toString()); // System.out.println(service.getWeather()); } } /**http://api.apixu.com/v1/current.json?key=aebe5a3f024040ff9bf112640160705&q=Paris**/