0

コード、messge、calctime、city、id、country、name を解析するには、次の URL を使用します。http://openweathermap.org/data/2.1/forecast/city/524901

{    "cod":"200","message":"kf","calctime":0.0342,"url":"http:\/\/openweathermap.org\/city\/524901",
            "city":
                  {
                    "id":524901,
                       "coord":                
                           {
                            "lon":37.615555,"lat":55.75222
                            },
                         "country":"RU","name":"Moscow","dt_calc":1356948005,"stations_count":6
                    },
4

2 に答える 2

4

以下のコードに従ってください。

JSONObject jObj=new JSONObject(jsonResponse);
String msg=jObj.getString("message");
String calctime=jObj.getString("calctime");
于 2013-01-01T05:56:09.647 に答える
1

上記のURLから解析コード、messge、calctime、city、id、country、nameに以下のコードを使用すると、問題が解決します。

JSONObject mJsonObj = new JSONObject(mJsonResponse);
String mCode = mJsonObj.getString("cod");
String mMessage = mJsonObj.getString("message");
String mCalcTime = mJsonObj.getString("calctime");

JSONObject mJsonCityObj = mJsonObj.getJSONObject("city");
String mId = mJsonCityObj.getString("id");
String mConuntry = mJsonCityObj.getString("country");
String mName = mJsonCityObj.getString("name");
于 2013-01-01T06:08:44.673 に答える