This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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

get the result of a URL query

Sukhwinder Brar

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("" + city);
URLConnection myURLConnection = myURL.openConnection();

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

Joined: Oct 14, 2005
Posts: 18541

Yes, that's JSON. (I tried your URL with my city at the end and got a lot of JSON in my browser.)
jQuery in Action, 2nd edition
subject: get the result of a URL query