Collects all keys in {@code jsonObject}.

@param jsonObject the {@link JSONObject} to get the keys of
@return the set of keys
190200
public static Set<String> getKeys(JSONObject jsonObject) {
        Set<String> keys = new TreeSet<String>();
        Iterator<?> iter = jsonObject.keys();
        while (iter.hasNext()) {
            keys.add((String) iter.next());
        }
        return keys;
    }
650713
public JSONObject getJSONObject( String key ) {
      verifyIsNull();
      Object o = get( key );
      if( JSONNull.getInstance()
            .equals( o ) ){
         return new JSONObject( true );
      }else if( o instanceof JSONObject ){
         return (JSONObject) o;
      }
      throw new JSONException( "JSONObject[" + JSONUtils.quote( key ) + "] is not a JSONObject." );
   }
391817
public JSONObject getJSONObject(String name) throws JSONException {
		Object object = get(name);
		if (object instanceof JSONObject) {
			return (JSONObject) object;
		}
		else {
			throw JSON.typeMismatch(name, object, "JSONObject");
		}
	}
150705
public JSONObject getJSONObject(String key) throws JSONException {
    Object o = get(key);
    if (o instanceof JSONObject) {
      return (JSONObject) o;
    }
    throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONObject.");
  }
1345203
@javax.annotation.Nonnull
  public JsonObject getJson() {
    @javax.annotation.Nonnull final JsonObject json = new JsonObject();
    json.addProperty("min", min);
    json.addProperty("max", max);
    json.addProperty("negatives", negatives);
    json.addProperty("positives", positives);
    json.addProperty("zeros", zeros);
    json.addProperty("sum0", sum0);
    json.addProperty("sum1", sum1);
    json.addProperty("sum2", sum2);
    json.addProperty("sumLog", sumLog);
    return json;
  }
250499
public function loadJSONObject($jsonObject)
    {
        if (isset($jsonObject->email)) {
            $this->setEmail($jsonObject->email);
        }
        if (isset($jsonObject->issues)) {
            $this->setIssues($jsonObject->issues);
        }
        if (isset($jsonObject->forum)) {
            $this->setForum($jsonObject->forum);
        }
        if (isset($jsonObject->wiki)) {
            $this->setWiki($jsonObject->wiki);
        }
        if (isset($jsonObject->irc)) {
            $this->setIrc($jsonObject->irc);
        }
        if (isset($jsonObject->source)) {
            $this->setSource($jsonObject->source);
        }
        if (isset($jsonObject->docs)) {
            $this->setDocs($jsonObject->docs);
        }
        if (isset($jsonObject->rss)) {
            $this->setRss($jsonObject->rss);
        }
        if (isset($jsonObject->chat)) {
            $this->setChat($jsonObject->chat);
        }

        return $this;
    }
548419
public JSONObject toJSON() throws JSONException {
        JSONObject json = new JSONObject();

        json.put(JSON_TYPE, this.getType());

        return json;
    }
548125
public JSONObject getJSONObject( int index ) {
      Object o = get( index );
      if( JSONNull.getInstance()
            .equals( o ) ){
         return new JSONObject( true );
      }else if( o instanceof JSONObject ){
         return (JSONObject) o;
      }
      throw new JSONException( "JSONArray[" + index + "] is not a JSONObject." );
   }
1027700
private List<String> objectKeys(JsonObject obj) {
    List<String> keys = new ArrayList<>();
    for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
      keys.add(entry.getKey());
    }
    return keys;
  }
1330026
public static JSONObject beanToJson(Object object) throws IllegalAccessException, InvocationTargetException {
        Method[] methods = object.getClass().getMethods();
        JSONObject jsonObject = new JSONObject();
        for (Method method : methods) {
            String name = method.getName();
            if (name.startsWith("get") && !"getClass".equals(name)) {
                name = name.substring(3);
                jsonObject.put(name.substring(0, 1).toLowerCase() + name.substring(1), method.invoke(object));
            } else if (name.startsWith("is")) {
                jsonObject.put(name, method.invoke(object));
            }
        }
        return jsonObject;
    }
1182522
static boolean hasHits(@Nullable JSONObject jsonObject) {
        if (jsonObject == null) {
            return false;
        }

        JSONArray resultHits = jsonObject.optJSONArray("hits");
        if (resultHits == null) {
            return false;
        }

        for (int i = 0; i < resultHits.length(); ++i) {
            JSONObject hit = resultHits.optJSONObject(i);
            if (hit != null) {
                return true;
            }
        }
        return false;
    }
533349
public static Object toBean( JSONObject jsonObject ) {
      if( jsonObject == null || jsonObject.isNullObject() ){
         return null;
      }

      DynaBean dynaBean = null;

      JsonConfig jsonConfig = new JsonConfig();
      Map props = JSONUtils.getProperties( jsonObject );
      dynaBean = JSONUtils.newDynaBean( jsonObject, jsonConfig );
      for( Iterator entries = jsonObject.names( jsonConfig )
            .iterator(); entries.hasNext(); ){
         String name = (String) entries.next();
         String key = JSONUtils.convertToJavaIdentifier( name, jsonConfig );
         Class type = (Class) props.get( name );
         Object value = jsonObject.get( name );
         try{
            if( !JSONUtils.isNull( value ) ){
               if( value instanceof JSONArray ){
                  dynaBean.set( key, JSONArray.toCollection( (JSONArray) value ) );
               }else if( String.class.isAssignableFrom( type )
                     || Boolean.class.isAssignableFrom( type ) || JSONUtils.isNumber( type )
                     || Character.class.isAssignableFrom( type )
                     || JSONFunction.class.isAssignableFrom( type ) ){
                  dynaBean.set( key, value );
               }else{
                  dynaBean.set( key, toBean( (JSONObject) value ) );
               }
            }else{
               if( type.isPrimitive() ){
                  // assume assigned default value
                  log.warn( "Tried to assign null value to " + key + ":" + type.getName() );
                  dynaBean.set( key, JSONUtils.getMorpherRegistry()
                        .morph( type, null ) );
               }else{
                  dynaBean.set( key, null );
               }
            }
         }catch( JSONException jsone ){
            throw jsone;
         }catch( Exception e ){
            throw new JSONException( "Error while setting property=" + name + " type" + type, e );
         }
      }

      return dynaBean;
   }
1041747
public String getLinkColor(JSONObject jsonObject){
        if(jsonObject == null) return null;
        try {
            return jsonObject.has("color") ? jsonObject.getString("color") : "";
        } catch (JSONException e) {
            Logger.v("Unable to get Link Text Color with JSON - "+e.getLocalizedMessage());
            return null;
        }
    }
842453
@SuppressWarnings("unchecked")
    public Collection<String> getPropertyKeys(Object obj) {
        if (isArray(obj)) {
          throw new UnsupportedOperationException();
        } else {
            return ((Map) obj).keySet();
        }
    }
781330
public static Map<String, Comparable> fromJsonObject(JsonObject object) {
        if (object == null || object.isNull() || object.isEmpty()) {
            return Collections.emptyMap();
        }
        Map<String, Comparable> map = MapUtil.createHashMap(object.size());
        for (String propertyName : object.names()) {
            map.put(propertyName, object.get(propertyName).asString());
        }
        return map;
    }
1033219
public JSONObject toJSON() {
        JSONObject ret = super.toJSON();
        if (arguments != null && arguments.size() > 0) {
            ret.put("arguments", arguments);
        }
        ret.put("operation", operation);
        return ret;
    }
9885
public static State jsonObjectToState(JsonObject jsonObject, String... excludeKeys) {
    State state = new State();
    List<String> excludeKeysList = excludeKeys == null ? Lists.<String>newArrayList() : Arrays.asList(excludeKeys);
    for (Map.Entry<String, JsonElement> jsonObjectEntry : jsonObject.entrySet()) {
      if (!excludeKeysList.contains(jsonObjectEntry.getKey())) {
        state.setProp(jsonObjectEntry.getKey(), jsonObjectEntry.getValue().getAsString());
      }
    }
    return state;
  }