이 기사의 예는 Java가 Weather Weather Network API를 부르는 방식을 알려줍니다. 참조를 위해 모든 사람을 위해 공유하십시오. 특정 구현 방법은 다음과 같습니다.
// Bingcheng Harbin은 중국 날씨 API를 통해 날씨 정보를 호출합니다. response <stringshandler = httget, system.out.println (jsonparser); JSONOBJECT JSO = JSO.GETASSTRING (); jso.get ( "temp1") 조건 // String j_weather = jso.get ( "Weather1"). // Wind Direction // j_wind = "wind1"); // info.append ( "오늘 :") .Appnd ( "") .appnd ( "") .appnd (j_wind) .appnd ( "////////// // n "); // info.append ("내일 : "). Append (m) .appnd (") .appnd ( "") .appnd (m_wind) .apend ( " /n "); //} string updtime = jso.get (" "fchh") if (updtime! = null) {if (! updtime.trim ()) { // 온도 J = jso.get ( "temp1"); get ( "weather1"( "weather1" ") .getAsstring (); // 오늘 문자열 m_weather = jso.get ("weather2 "). getAsstring (); // 내일 // 바람 방향 바람 힘 스트링 j_wind = jso.get "Wind1"). ") .appnd (j_weather).) .appnd (j_wind) .appnd ("/n "); info.append ("내일 : ") .appnd (" ") .appnd (m_weather). appnd ( "") .append (m_wind) .appnd ( "/n")} else {// 온도 문자열 temp1 = jso.get ( "temp1"); jso.get ( "temp2"). 0]; String M = Split ( "~") [1] + " +") [0]; ". "; (weather2.indexof ( "turn")> 0) {// j_weather_part2 = weather2.split ( "turn") [0];} else {j_weather_part2 = weather2;} i f (j_weather_part1.equalsignorecase (j_weather_part2)) {j_weather = j_weather_part1; .indexof ( "turn")> 0) {// m_weather_part1 = weather2.split ( "turn") [1];} else {m_weather_part1 = weather2;} if (weather3.indexof ( "turn ("turn to "”가 있습니다. ) {// m_weather_part2 = weather3.split ( "turn") [0];} else {m_weather_part2 = weather3;} if (m_weather_part1.equalsignorecase (m_weather_part2)) {m_weather = m_weather_part1; {m_weather = m_weather_part1 + " + m_weather_part2; 내일 정보 ( "오늘 :"). Append (j) .appnd ( "") .appnd ( "") .appnd ( "/n"( "/n"). ; ( ""내일 : "). Append (m) .appnd (" ") .appnd (m_weather) .appnd (" ") .apend (m_wind) .appnd ("/n ");}}}}. }}}}}}}}}}}}}}}}}}}}}}}}} catch (예외 e) {} return info.toString ();}
이 기사는 모든 사람의 Java 프로그램 설계에 도움이되기를 바랍니다.