많고 많은 라이브러리 중 하나.
보통은 json-simple 을 사용하는 것으로 알고 있다.

Json 오브젝트에서 Key의 메타 데이터를 가져올 수 있는 라이브러리가 있는지 확인하는 과정에서 나온 라이브러리. 원하는 건 못찾았다.


          try {
               JSONObject jObject = new JSONObject(jString);

               // menu jsonobject 생성
               JSONObject responseObject = jObject.getJSONObject("response");

              
               JSONObject header = responseObject.getJSONObject("header");
               System.out.println(header.toString());
              
               String resultMsg = header.getString("resultMsg");
               System.out.println(resultMsg);
               String resultCode = header.getString("resultCode");
               System.out.println(resultCode);

              
               JSONObject body = jObject.getJSONObject("response").getJSONObject("body");

               JSONArray item = body.getJSONObject("items").getJSONArray("item");
              
               for(int i=0; i<item.length(); i++){
                    JSONObject item_o =item.getJSONObject(i);
                    System.out.println(item_o.toString());
                   
                    int rnum = item_o.getInt("rnum");
                    System.out.println(rnum);
                    int code = item_o.getInt("code");
                    System.out.println(code);
                    String name = item_o.getString("name");
                    System.out.println(name);
                   
                    /*String rnum = item.getJSONObject(i).getString("rnum");
                    System.out.println(rnum);
                    String code = item.getJSONObject(i).getString("code");
                    System.out.println(code);
                    String name = item.getJSONObject(i).getString("name");
                    System.out.println(name);*/
               }
               int numOfRows = body.getInt("numOfRows");
               System.out.println(numOfRows);
               int pageNo = body.getInt("pageNo");
               System.out.println(pageNo);
               int totalCount = body.getInt("totalCount");
               System.out.println(totalCount);
              
    

          } catch (JSONException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          }


+ Recent posts