-
Anonymous
Как мне проанализировать следующий json "OpenWeathermap"
Сообщение
Anonymous »
Я использую
www.openweathermap.org. Это является результатом прогноза:
http://api.openweathermap.org/data/2.5/ ... 35&lon=139
Код: Выделить всё
JSONObject coordObj = getObject("coord", jObj);
Latitude = getFloat("lat", coordObj);
Longitude = getFloat("lon", coordObj);
JSONObject coordObj = getObject("city", jObj);
id = getFloat("id", coordObj);
name = getFString("name", coordObj);
JSONObject sysObj = getObject("sys", jObj);
Country = getString("country", sysObj);
Sunrise = getInt("sunrise", sysObj));
Sunset = getInt("sunset", sysObj));
JSONObject jlist = jObj.getObject("list");
JSONObject JSONWeather = jArr.getJSONObject(0);
Condition_id == getInt("id", JSONWeather);
condition_description = getString("description", JSONWeather);
condition = getString("main", JSONWeather);
condition_icongetString("icon", JSONWeather);
JSONObject mainObj = getObject("main", jObj);
Humidity = getInt("humidity", mainObj);
Pressure = getInt("pressure", mainObj);
MaxTemp = getFloat("temp_max", mainObj);
MinTemp(getFloat("temp_min", mainObj);
Temp = getFloat("temp", mainObj);
// Wind
JSONObject wObj = getObject("wind", jObj; Speed = getFloat("speed", wObj); Deg = getFloat("deg", wObj);
// Clouds
JSONObject cObj = getObject("clouds", jObj); Perc = getInt("all", cObj);
Как cam a lip погодный массив?
Подробнее здесь:
https://stackoverflow.com/questions/169 ... weathermap
1758881513
Anonymous
Я использую www.openweathermap.org. Это является результатом прогноза: http://api.openweathermap.org/data/2.5/forecast?lat=35&lon=139
[code]JSONObject coordObj = getObject("coord", jObj);
Latitude = getFloat("lat", coordObj);
Longitude = getFloat("lon", coordObj);
JSONObject coordObj = getObject("city", jObj);
id = getFloat("id", coordObj);
name = getFString("name", coordObj);
JSONObject sysObj = getObject("sys", jObj);
Country = getString("country", sysObj);
Sunrise = getInt("sunrise", sysObj));
Sunset = getInt("sunset", sysObj));
JSONObject jlist = jObj.getObject("list");
JSONObject JSONWeather = jArr.getJSONObject(0);
Condition_id == getInt("id", JSONWeather);
condition_description = getString("description", JSONWeather);
condition = getString("main", JSONWeather);
condition_icongetString("icon", JSONWeather);
JSONObject mainObj = getObject("main", jObj);
Humidity = getInt("humidity", mainObj);
Pressure = getInt("pressure", mainObj);
MaxTemp = getFloat("temp_max", mainObj);
MinTemp(getFloat("temp_min", mainObj);
Temp = getFloat("temp", mainObj);
// Wind
JSONObject wObj = getObject("wind", jObj; Speed = getFloat("speed", wObj); Deg = getFloat("deg", wObj);
// Clouds
JSONObject cObj = getObject("clouds", jObj); Perc = getInt("all", cObj);
[/code]
Как cam a lip погодный массив?
Подробнее здесь: [url]https://stackoverflow.com/questions/16923883/how-do-i-parse-the-following-json-openweathermap[/url]