POSA-15 icon indicating copy to clipboard operation
POSA-15 copied to clipboard

Wrong names of JSON objects in Main class (assignment 3)

Open psmorandi opened this issue 9 years ago • 4 comments

Instead of

    public final static String tempMin_JSON = "tempMin";
    public final static String tempMax_JSON = "tempMax";
    public final static String seaLevel_JSON = "seaLevel";
    public final static String grndLevel_JSON = "grndLevel";

should be

    public final static String tempMin_JSON = "temp_min";
    public final static String tempMax_JSON = "temp_max"; 
    public final static String seaLevel_JSON = "sea_level";
    public final static String grndLevel_JSON = "grnd_level";

See this return example from API: http://api.openweathermap.org/data/2.5/weather?q=Lima&units=metric

"main":{"temp":17.03,"temp_min":17.03,"temp_max":17.03,"pressure":866.88,"sea_level":1025.82,"grnd_level":866.88,"humidity":77},

psmorandi avatar Jun 01 '15 01:06 psmorandi

Paulo, when running http://api.openweathermap.org/data/2.5/weather?q=Lima&units=metric we don't get anything with sea_level or grnd_level in it. Here's what we get:

{"coord":{"lon":-84.11,"lat":40.74},"sys":{"type":3,"id":154950,"message":0.3679,"country":"US","sunrise":1433153223,"sunset":1433206895},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"base":"stations","main":{"temp":9.52,"humidity":90,"pressure":1021,"temp_min":9.44,"temp_max":10},"wind":{"speed":1.54,"gust":4.11,"deg":32},"rain":{"1h":0.51},"clouds":{"all":92},"dt":1433158525,"id":5160783,"name":"Lima","cod":200}

How are you getting these values?

Thanks,

Doug

douglascraigschmidt avatar Jun 01 '15 11:06 douglascraigschmidt

Hello @douglascraigschmidt, sorry I think I put the value from another query that I did. The weird thing is that this URL http://api.openweathermap.org/data/2.5/weather?q=x&units=metric gives this info. If you change x with Taypano (with seems to be the city) gives 404.

Here the full json:

{"coord":{"lon":124.56,"lat":8.37},"sys":{"message":0.9566,"country":"PH","sunrise":1433107334,"sunset":1433152618},"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10n"}],"base":"stations","main":{"temp":21.68,"temp_min":21.68,"temp_max":21.68,"pressure":957.98,"sea_level":1023.41,"grnd_level":957.98,"humidity":100},"wind":{"speed":1.96,"deg":155.002},"rain":{"3h":4.165},"clouds":{"all":88},"dt":1433165003,"id":1684361,"name":"Taypano","cod":200}

psmorandi avatar Jun 01 '15 13:06 psmorandi

Paulo, can you please send me a link that demonstrates this behavior. This link gets 404 http://api.openweathermap.org/data/2.5/weather?q=Taypano&units=metric, as does this link http://api.openweathermap.org/data/2.5/weather?q=x&units=metric.

Thanks,

Doug

douglascraigschmidt avatar Jun 01 '15 14:06 douglascraigschmidt

Strange, see this picture:

image

This is the return for me of the second URL (http://api.openweathermap.org/data/2.5/weather?q=x&units=metric).

Could be browser related?

Try this one: http://api.openweathermap.org/data/2.5/weather?q=Umuarama&units=metric the city where I was born :)

image

psmorandi avatar Jun 01 '15 14:06 psmorandi