JSONObject Java equivalent for Objective C



我正在为目标C开发一个API,该API具有等效的JAVA版本。他们使用JSON.org元素来定义JAVA中的JSON解析。

 import org.json.JSONObject;
 public class TestCodeRequest{
    private HashMap<String,JSONObject> query = new HashMap<String, JSONObject>();
    private JSONObject queryResult;
 }

    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;
   }

我想NSDictionary是HashMap的一个目标C等价物。我使用JSONKit进行JSON解析。想知道在这种情况下什么是JSONObject。

JSONObject等价于NSDictionary(名称/值或键/值对的无序集合)。