I am looking to get the weather from this weather API I am using in a Netbeans Java project into my own Maven API, this is all working fine but returning a huge chunky JSON response when I want to break it down into smaller readable text.
My code is currently returning:
{"coord":{"lon":-6.26,"lat":53.35},"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"base":"stations","main":{"temp":285.59,"pressure":1015,"humidity":58,"temp_min":285.15,"temp_max":286.15},"visibility":10000,"wind":{"speed":3.6,"deg":80},"clouds":{"all":20},"dt":1539610200,"sys":{"type":1,"id":5237,"message":0.0027,"country":"IE","sunrise":1539586357,"sunset":1539624469},"id":2964574,"name":"Dublin","cod":200}
I would instead like it to be able to return, main in weather and temp in weather as well. If anyone has any ideas let me know. Code is attached.
public class WeatherInfo {
public static String getWeather(String city) {
String weather;
String getUrl = "http://api.openweathermap.org/data/2.5/weather?q="+ city +"&appid=xxx";
Client client = Client.create();
WebResource target = client.resource(getUrl);
ClientResponse response = target.get(ClientResponse.class);
weather = response.getEntity(String.class);
return weather;
}
}