Package org.json

Examples of org.json.JSONObject.keys()


      recordType = contextName;
      if (!contextName.equals(recordName)) {
        recordType += "_" + recordName;
      }

      Iterator<String> ki = json.keys();
      while (ki.hasNext()) {
        String key = ki.next();
        String value = json.getString(key);
        if(value != null) {
          chukwaRecord.add(key, value);
View Full Code Here


    JSONObject prefs = json.optJSONObject("prefs");
    if (prefs == null) {
      return null;
    }
    Map<String, String> p = Maps.newHashMap();
    Iterator i = prefs.keys();
    while (i.hasNext()) {
      String key = (String)i.next();
      p.put(key, prefs.getString(key));
    }
    return new UserPrefs(p);
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

   {
      JSONObject jsonUserPref = new JSONObject(userPref != null ? userPref : "{}");

      // Update the user Preferences with the new value. Replace the old ones if they exist.
      JSONObject addedJSONUserPref = new JSONObject(addedUserPref);
      for (Iterator<String> i = addedJSONUserPref.keys();i.hasNext();)
      {
         String key = i.next();
         jsonUserPref.put(key, addedJSONUserPref.get(key));
      }
View Full Code Here

        Map<String, String> mapMetaData = new HashMap<String, String>();
        String metadata = fetchGagdetRpcMetadata(url);
        metadata = metadata.substring(metadata.indexOf("[") + 1, metadata.lastIndexOf("]"));
        JSONObject jsonObj = new JSONObject(metadata).getJSONObject(UIGadget.RPC_RESULT).getJSONObject(url)
                .getJSONObject(UIGadget.METADATA_MODULEPREFS);
        Iterator<String> iter = jsonObj.keys();
        while (iter.hasNext()) {
            String element = iter.next();
            mapMetaData.put(element, jsonObj.get(element).toString());
        }
        return mapMetaData;
View Full Code Here

    public void addUserPref(String addedUserPref) throws JSONException {
        JSONObject jsonUserPref = new JSONObject(userPref != null ? userPref : "{}");

        // Update the user Preferences with the new value. Replace the old ones if they exist.
        JSONObject addedJSONUserPref = new JSONObject(addedUserPref);
        for (Iterator<String> i = addedJSONUserPref.keys(); i.hasNext();) {
            String key = i.next();
            jsonUserPref.put(key, addedJSONUserPref.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

            // check to see if this gadget has at least one non-hidden user pref
            // to determine if we should display the edit prefs button
            boolean hasPrefsToEdit = false;
            if (responseObject.has(USER_PREFS)) {
                JSONObject userPrefs = responseObject.getJSONObject(USER_PREFS);
                Iterator keys = userPrefs.keys();
                while(keys.hasNext()) {
                    String userPrefName = (String) keys.next();
                    JSONObject userPref = userPrefs.getJSONObject(userPrefName);
                    if (!PrefDataTypes.HIDDEN.toString().equals(userPref.getString(DATA_TYPE))) {
                        hasPrefsToEdit = true;
View Full Code Here

    IOUtils.copy(is, writer, "UTF-8");
    JSONArray json = new JSONArray(writer.toString());
    Map<String, String> content = new HashMap<String, String>();
    for (int i = 0; i < json.length(); i++) {
      JSONObject entry = json.getJSONObject(i);
      String key = (String) entry.keys().next();
      content.put(key, entry.getString(key));
    }

    factory = new ClientSideCriteriaFactory(content);
View Full Code Here

    if (o == null) {
      return new HashMap<String, byte[]>();
    }

    Map<String, byte[]> files = new HashMap<String, byte[]>();
    for (Iterator<String> pathsIter = o.keys(); pathsIter.hasNext();) {
      String path = pathsIter.next();
      String base64Content;
      try {
        base64Content = o.getString(path);
      } catch (JSONException e) {
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.