Получение JSONObject из источника URL-Json.json parsing data from url получение nullpointException
public class source02 {
public static void main(String[] args) {
try {
URL url = new URL("http://openapi.seoul.go.kr:8088/sample/json/StationDayTrnsitNmpr/1/5/");
InputStreamReader isr = new InputStreamReader(url.openConnection().getInputStream(), "UTF-8");
JSONObject object = (JSONObject)JSONValue.parse(isr);
JSONObject sdt = (JSONObject) object.get("StationDayTrnsitNmpr");
System.out.println(sdt.get("list_total_count").toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
и источник Json
{"StationDayTrnsitNmpr":{"list_total_count":44,"RESULT":{"CODE":"INFO-000","MESSAGE":"정상 처리되었습니다"},"row":[{"SN":"1","STATN_NM":"신도림","WKDAY":333873.0,"SATDAY":298987.0,"SUNDAY":216886.0},{"SN":"2","STATN_NM":"동대문역사문화공원","WKDAY":251049.0,"SATDAY":211456.0,"SUNDAY":150589.0},{"SN":"3","STATN_NM":"충무로","WKDAY":229882.0,"SATDAY":194865.0,"SUNDAY":142150.0},{"SN":"4","STATN_NM":"종로3가","WKDAY":224539.0,"SATDAY":196606.0,"SUNDAY":142525.0},{"SN":"5","STATN_NM":"사당","WKDAY":200985.0,"SATDAY":180230.0,"SUNDAY":134354.0}]}}
получение java.lang.NullPointerException в api.source02.main (source02.java:16)
Что такое линия 16? Также зарегистрируйте 'object', чтобы увидеть, как он представлен. –