2016-06-23 1 views
2

Java에서 json의 특정 속성 (json 하위 집합)을 추출하는 데 사용할 수있는 API/도구가 있습니까? apache-commons beanutils 복사와 유사합니까? 예를 들어주 json의 속성이 거의없는 json 하위 집합 추출

나는이

{ 
    "fixed":[ 
     { 
     "b":"some value", 
     "c":"some value", 
     "d":"some value", 
     "e":"some value", 
     "f":"some value" 
     }, 
     { 
     "b":"value", 
     "c":"value", 
     "d":"value", 
     "e":"value", 
     "f":"value" 
     } 
    ] 
} 

내가하지만 확실하지, 내가 와서 다음과 같은 JSON

{ 
    "fixed":[ 
     { 
     "b":"some value", 
     "e":"some value", 
     "f":"some value" 
     }, 
     { 
     "b":"value", 
     "e":"value", 
     "f":"value" 
     } 
    ] 
} 

에게 다음과 같은 방법을하고 싶은 다음 JSON의 올바른 접근 방식

경우
public JSONObject parseJSON(JSONObject data,List<String> subset){ 
     JSONArray fixedArray = (JSONArray) data.get("fixed"); 
     JSONObject resObj = new JSONObject(); 
     JSONArray resArray = new JSONArray(); 
     for(int i=0;i<fixedArray.size();i++){ 
      JSONObject element = (JSONObject) fixedArray.get(i); 
      JSONObject resElement = new JSONObject(); 
      for(String s:subset){ 
       resElement.put(s, element.get(s)); 
      } 
      resArray.add(resElement); 
     } 
     return resObj.put("fixed", resArray); 
} 

나는 this을 보았으나 t에는 도움이되지 않았다. 그의 주제.

답변