http://www.worldweatheronline.com JSON 피드의 날씨 정보를 구문 분석하려고합니다. JSON 배열 배열 분석 (Android)
{ "data" : { "current_condition" : [ { "cloudcover" : "75",
"humidity" : "100",
"observation_time" : "10:01 PM",
"precipMM" : "0.0",
"pressure" : "1015",
"temp_C" : "3",
"temp_F" : "37",
"visibility" : "4",
"weatherCode" : "143",
"weatherDesc" : [ { "value" : "Mist" } ],
"weatherIconUrl" : [ { "value" : "http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0006_mist.png" } ],
"winddir16Point" : "N",
"winddirDegree" : "360",
"windspeedKmph" : "11",
"windspeedMiles" : "7"
} ],
은 그래서에서 값을 얻기 위해 관리 한
current_condition JSONArray
,이 : 이것은에서 오는 형식입니다. 그렇다면 내부 배열
weatherDesc
또는
weatherIconUrl
에서 값을 읽으려면 어떻게해야합니까? 당신은 루프에 대한 내부 항목에 즉하여 액세스 할 수 있도록
String precipMM = null;
try {
JSONObject data = json.getJSONObject("data");
JSONArray current_condition = data.getJSONArray("current_condition");
for(int i = 0; i < current_condition.length(); i++) {
precipMM = current_condition.getJSONObject(i).getString("precipMM");
}
} catch (JSONException e) {
e.printStackTrace();
}
안녕하세요 매트, 잭슨 도서관을 사용하지 않고도이 기능을 사용할 수 있었습니까? 나는 비슷한 상황에 처해있다. –