wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes get the result of a URL query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "get the result of a URL query" Watch "get the result of a URL query" New topic
Author

get the result of a URL query

Sukhwinder Brar
Greenhorn

Joined: Feb 05, 2013
Posts: 1
Hi! I am developing a weather forecast application which uses OpenWeatherMaps API to find the forecasts for next seven days for a city. I am new to API as well as JSON. So, I have used the API as following:

public void findWeather(String city){

try {
URL myURL = new URL("http://api.openweathermap.org/data/2.1/forecast/city?q=" + city);
System.out.print(myURL.getContent());
URLConnection myURLConnection = myURL.openConnection();
myURLConnection.connect();
}

catch (MalformedURLException e) {
JOptionPane.showMessageDialog(null, e);
}
catch (IOException e) {
JOptionPane.showMessageDialog(null, e);
}
}
}

Now, if you try to copy the URL and paste it in your browser while replacing city by any city name, you get the result but they are in JSON I think. All I want is to parse that result into a table or list which I can display on my GUI.

Any kind of help is appreciated..
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yes, that's JSON. (I tried your URL with my city at the end and got a lot of JSON in my browser.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get the result of a URL query