JSONObject Java equivalent for Objective C -
i'm working on api objective c has equivalent java version. used json.org elements define json parsing in java.
import org.json.jsonobject; public class testcoderequest{ private hashmap<string,jsonobject> query = new hashmap<string, jsonobject>(); private jsonobject queryresult; }
and
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; (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 constraint, '" + fields[i] +"' value."); } } else { sq = new jsonobject(); tmp.put((string)fields[i], sq); } } sq.put((string)fields[fields.length-2], fields[fields.length-1]); return this; }
i guess nsdictionary objective c equivalent hashmap. i'm using jsonkit json parsing. wondering jsonobject in case.
jsonobject
equivalent nsdictionary
(an unordered collection of name/value or key/value pairs).
Comments
Post a Comment