2013-08-24 3 views
2

동등한 JAVA 버전을 가진 objective C 용 API를 개발 중입니다. 그들은 JSON.org 요소를 사용하여 JAVA에서 JSON 구문 분석을 정의했습니다. JSONObject Objective C에 해당하는 Java

public TestCodeRequest add(String endpoint, Object... fields) { 
     JSONObject endpointQuery; 
     if ((endpointQuery = query.get(endpoint)) == null) { 
      endpointQuery = new JSONObject(); 
      query.put(endpoint,endpointQuery); 
      } 
     JSONObject sq = endpointQuery; 
     for (int i=0;i<fields.length-2;i++) { 
     JSONObject tmp = sq; 
     if(sq.has((String)fields[i])){ 
     try { 
      sq = sq.getJSONObject((String)fields[i]); 
      } catch(Exception e) { 
       throw new Semantics3Exception(
         "Invalid constraint", 
         "Cannot add this constraint, '" + fields[i] +"' is already a  value."); 
           } 
     } else { 
      sq = new JSONObject(); 
      tmp.put((String)fields[i], sq); 
     } 
    } 
     sq.put((String)fields[fields.length-2], fields[fields.length-1]); 
     return this; 
    } 

import org.json.JSONObject; 

public class TestCodeRequest{ 
    private HashMap<String,JSONObject> query = new HashMap<String, JSONObject>(); 
    private JSONObject queryResult; 

} 

난 NSDictionary와는 HashMap에 대한 목표 C 동등한 것 같다. JSON 구문 분석을 위해 JSONKit을 사용하고 있습니다. 이 경우 JSONObject가 무엇인지 궁금합니다.

답변

4

JSONObjectNSDictionary (이름/값 또는 키/값 쌍의 정렬되지 않은 모음)과 동일합니다.

관련 문제