Get the int value associated with a key.

@param key
A key string.
@return The integer value.
@throws JSONException
if the key is not found or if the value cannot be converted to an integer.
765839
public int getInt(String key) throws JSONException {
    Object o = get(key);
    try {
      return o instanceof Number ? ((Number) o).intValue() : Integer.parseInt((String) o);
    } catch (Exception e) {
      throw new JSONException("JSONObject[" + quote(key) + "] is not an int.");
    }
  }
501311
public int getRequiredInt(String key) {
        Optional<Integer> value = getInteger(key);
        if (value.isPresent()) {
            return value.get();
        }
        throw new IllegalStateException(String.format("required key [%s] not found", key));
    }
1022418
public int getInt(int key)
    {
        Object value = map.get(key);
        if (!(value instanceof Integer))
        {
            return 0;
        }
        Integer result = (Integer)value;
        return result;
    }
112624
private Integer getIntegerField(JsonNode json, String fieldName) {
        if (!json.has(fieldName)) {
            return null;
        }
        return json.get(fieldName).intValue();
    }
114243
public long getLong(String key) throws JSONException {
    Object o = get(key);
    try {
      return o instanceof Number ? ((Number) o).longValue() : Long.parseLong((String) o);
    } catch (Exception e) {
      throw new JSONException("JSONObject[" + quote(key) + "] is not a long.");
    }
  }
1058108
public static int getInt(JSONValue value) {
        if (value == null)
            return 0;
        if (!(value instanceof Number))
            throw new JSONException(NOT_A_NUMBER);
        return ((Number)value).intValue();
    }
1234608
public String getString( String key ) {
      verifyIsNull();
      Object o = get( key );
      if( o != null ){
         return o.toString();
      }
      throw new JSONException( "JSONObject[" + JSONUtils.quote( key ) + "] not found." );
   }
1331768
public Object get(String key) throws JSONException {
    Object o = opt(key);
    if (o == null) {
      throw new JSONException("JSONObject[" + quote(key) + "] not found.");
    }
    return o;
  }
96053
public final int get(String key)
  {

    for (int i = 0; i < m_firstFree; i++)
    {
      if (m_map[i].equals(key))
        return m_values[i];
    }

    return INVALID_KEY;
  }
161727
public static int getInt(final String key, final int def) {
		try {
			return systemRoot.getInt(fixKey(key), def);
		} catch (final Exception e) {
			// just eat the exception to avoid any system crash on system issues
			return def;
		}
	}
822297
public JSONArray getJSONArray( String key ) {
      verifyIsNull();
      Object o = get( key );
      if( o != null && o instanceof JSONArray ){
         return (JSONArray) o;
      }
      throw new JSONException( "JSONObject[" + JSONUtils.quote( key ) + "] is not a JSONArray." );
   }
574844
public int getInteger(int key) {
        Any3<Boolean, Integer, String> value = data.get(Any2.<Integer, String>left(key));
        if (value == null)
            throw new IllegalArgumentException("missing argument for param " + key);
        return value.get2().orElseThrow(() -> new IllegalArgumentException("expected integer argument for param " + key));
    }
547645
public int getInteger(String key, int defaultValue) {
		Object o = getObject(key);
		if (o == null) {
			return defaultValue;
		}
		int val = defaultValue;
		try {
			val = Integer.parseInt(o.toString());
		}
		catch (Exception e) {
			throw new IllegalArgumentException("Object ["+o+"] associated with key ["+key+"] is not of type Integer.");
		}
		return val;
	}
689481
public int getIndex(Object key) {
    Integer i = (Integer) nset.get(key);
    if (i == null) {
      return -1;
    }
    else {
      return i.intValue();
    }
  }
1350989
@Override
    public Integer getInteger(String key) {
        Integer r = super.getInteger(key);
        if (r == null) {
            LOGGER.error(ERROR_NOSUCHKEY + key + "\"");
            return null;
        }
        return r;
    }
818518
public int getInteger(String key) throws MissingResourceException {
        String result = getString(key);
        try {
            return Integer.parseInt(result);
        } catch (NumberFormatException nfe) {
            if (tc.isEventEnabled()) {
                Tr.event(tc, "Unable to parse " + result + " as Integer.");
            }
            // DGH20040823: Begin fix for defect 218797 - Source provided by Tom Musta
            // String msg = messages.getString("NLS.integerParseError",
            //                                 "Unable to parse as integer.");
            String msg = getMessages().getString("NLS.integerParseError",
                                                 "Unable to parse as integer.");
            // DGH20040823: End fix for defect 218797 - Source provided by Tom Musta
            throw new MissingResourceException(msg, bundleName, key);
        }
    }
328279
public JsonElement get(int index) throws JsonException {
        try {
            JsonElement value = values.get(index);
            if (value == null) {
                throw new JsonException("Value at " + index + " is null.");
            }
            return value;
        } catch (IndexOutOfBoundsException e) {
            throw new JsonException("Index " + index + " out of range [0.." + values.size() + ")");
        }
    }