반응형
JSON 형식의 데이터를 받아서 jqGrid에 뿌려주는 경우 참고하세요~
JSONParser parser = new JSONParser();
JSONObject jsonObject = null;
StringBuilder sbParam = new StringBuilder();
if(config.getProperty("mode").equalsIgnoreCase("local")){ //json 파일을 직접 불러서 jqGrid에 뿌려주는 경우
String jsonPath = '패스는 상황에 맞게 변경 할 것~';
Object obj = parser.parse(new FileReader(jsonPath));
jsonObject = (JSONObject)obj;
}else { // 서버 URL 호출로 JSON 형식으로 받아서 jqGrid에 JSONObject 형식으로 리턴하는 경우
String url = sbParam.toString();
URL getURL = new URL(url);
HttpURLConnection con = (HttpURLConnection)getURL.openConnection();
jsonObject = (JSONObject)parser.parse(new InputStreamReader(con.getInputStream()));
con.disconnect();
}
return jsonObject.toString();
반응형
'Java' 카테고리의 다른 글
PKIX path building failed 오류 해결법 (0) | 2017.09.27 |
---|---|
javax.persistence.xxx 가 무엇인가 ? (0) | 2016.11.11 |
자바 컬렉션 List, Map, Vector 입력 출력 (0) | 2016.10.04 |
HttpURLConnection클래스로 웹페이지 POST 호출 방법 (0) | 2016.09.29 |
자바 날짜 계산 참고 및 예제 (0) | 2016.09.28 |