Package org.json

Examples of org.json.JSONObject.keys()


                    if (!StringUtils.isBlank(encodedText)) {
                        //logger.debug("*** Encoded text: '"+encodedText+"'");
                        try {
                            JSONObject jsonObj = new JSONObject(encodedText);
                            OptionalParamMap optionalParams = new OptionalParamMap(OptionalParamMap.HASH_MAP);
                            Iterator<String> nameItr = jsonObj.keys();
                            while(nameItr.hasNext()) {
                                String name = nameItr.next();
                                Object o = jsonObj.get(name);
                                optionalParams.put(name, o);
                            }
View Full Code Here


  public DiffsResponse() {
  }

  protected static Map<String, Object> parseItem(String jsonObj) throws JSONException {
    JSONObject jsonItem = new JSONObject(jsonObj);
    Iterator<?> iter = jsonItem.keys();
    Map<String, Object> itemMap = Maps.newHashMap();
    while (iter.hasNext()) {
      String key = iter.next().toString();
      itemMap.put(key, jsonItem.getString(key));
    }
View Full Code Here

      JSONObject personData = db.getJSONObject(DATA_TABLE).optJSONObject(id);
      if (personData != null) {
        if (fields.contains(Person.Field.APP_DATA.toString())) {
          appData = Maps.newHashMap();
          @SuppressWarnings("unchecked")
          Iterator<String> keys = personData.keys();
          while (keys.hasNext()) {
            String key = keys.next();
            appData.put(key, personData.get(key));
          }
        } else {
View Full Code Here

        // TODO: We can use the converter here to do this for us

        // JSONObject keys are always strings
        @SuppressWarnings("unchecked")
        Iterator<String> keys = personData.keys();
        Map<String, String> data = Maps.newHashMap();
        while (keys.hasNext()) {
          String key = keys.next();
          data.put(key, personData.getString(key));
        }
View Full Code Here

      JSONObject newPersonData = new JSONObject();
      JSONObject oldPersonData = db.getJSONObject(DATA_TABLE).getJSONObject(user);

      // JSONObject keys are always strings
      @SuppressWarnings("unchecked")
      Iterator<String> keys = oldPersonData.keys();
      while (keys.hasNext()) {
        String key = keys.next();
        if (!fields.contains(key)) {
          newPersonData.put(key, oldPersonData.getString(key));
        }
View Full Code Here

      return;
    }

    if (current instanceof JSONObject) {
      JSONObject json = (JSONObject) current;
      Iterator<?> keys = json.keys();
      while (keys.hasNext()) {
        String key = (String) keys.next();
        if (json.isNull(key)) {
          result.put(prefix + '.' + key, "null");
        } else {
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  private static Object convertJsonElement(Object elem) throws JSONException {
    if (elem instanceof JSONObject) {
      JSONObject obj = (JSONObject) elem;
      Iterator<String> keys = obj.keys();
      Map<String, Object> jsonMap = new HashMap<String, Object>();
      while (keys.hasNext()) {
        String key = keys.next();
        jsonMap.put(key, convertJsonElement(obj.get(key)));
      }
View Full Code Here

  }

  public void initFromConfigString(String oauthConfigStr) throws GadgetException {
    try {
      JSONObject oauthConfigs = new JSONObject(oauthConfigStr);
      for (Iterator<?> i = oauthConfigs.keys(); i.hasNext();) {
        String url = (String) i.next();
        URI gadgetUri = new URI(url);
        JSONObject oauthConfig = oauthConfigs.getJSONObject(url);
        storeConsumerInfos(gadgetUri, oauthConfig);
      }
View Full Code Here

            throw new UnmarshallException("not a Map");
        JSONObject jsonmap = jso.getJSONObject("map");
        if (jsonmap == null)
            throw new UnmarshallException("map missing");
        ObjectMatch m = new ObjectMatch(-1);
        Iterator i = jsonmap.keys();
        String key = null;
        try {
            while (i.hasNext()) {
                key = (String) i.next();
                m = ser.tryUnmarshall(state, null, jsonmap.get(key)).max(m);
View Full Code Here

            throw new UnmarshallException("not a Map");
        }
        JSONObject jsonmap = jso.getJSONObject("map");
        if (jsonmap == null)
            throw new UnmarshallException("map missing");
        Iterator i = jsonmap.keys();
        String key = null;

        while (i.hasNext()) {
            key = (String) i.next();
            abmap.put(JSON.getObject(key.substring(0, key.indexOf("$mapHashID"))), JSON.getObject((String) jsonmap.get(key)));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.