Put a key/int pair in the JSONObject.

@param key   A key string.
@param value An int which is the value.
@return this
@throws JSONException If the key is null.
515589
public JSONObject put(String key, int value) throws JSONException {
        put(key, Integer.valueOf(value));
        return this;
    }
1104471
public function put($value, $key = NULL)
	{
		// disallow non-integer keys
		if($key !== NULL && gettype($key) != 'integer')
		{
			throw new JSONException('Key value must be an integer value');
		}
		
		if(gettype($value) == 'object' && !($value instanceof JSONObject) && !($value instanceof JSONArray))
		{
			$value = new JSONObject($value);
		}
		elseif(gettype($value) == 'array')
		{
			$value = new JSONArray($value);
		}
		
		$this->testValidity($value);
		
		if($key != NULL && in_array($key, $this->map))
			$this->map[$key] = $value;
		else
			$this->map[] = $value;
		
		return $this;
	}
1112873
public JSONObject element( String key, boolean value ) {
      verifyIsNull();
      return element( key, value ? Boolean.TRUE : Boolean.FALSE );
   }
473277
public JsonObject put(String name, Number value) {
        content.put(name, value);
        return this;
    }
206417
public IntReference put(K key, int value)
    {
        IntReference w = map.get(key);
        if (w == null)
        {
            w = new IntReference(value);
            return map.put(key, w);
        }
        else
        {
            w.value = value;
            return null;
        }
    }
511873
public void setValue(String key, String value) {
        KeyValue kv = getKV(key);
        if (kv != null) {
            kv.setValue(value);
        } else if (key != null) {
            map.add(new KeyValue(key,value));
        }
    }
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();
    }
1255851
@SuppressWarnings("unchecked")
    public void setProperty(Object obj, Object key, Object value) {
        if (isMap(obj))
            ((Map) obj).put(key.toString(), value);
        else {
            throw new JsonPathException("setProperty operation cannot be used with " + obj!=null?obj.getClass().getName():"null");
        }
    }
442244
public JSONObject element( String key, long value ) {
      verifyIsNull();
      return element( key, new Long( value ) );
   }
1231343
public B set(String key, int value) {
        this.data.put(key, value);
        return (B) this;
    }
127650
protected static JSONObject propertyPut(JSONObject jsonObject, Object key, Object value) {
		String keyStr = Convert.toStr(key);
		String[] path = StrUtil.split(keyStr, StrUtil.DOT);
		int last = path.length - 1;
		JSONObject target = jsonObject;
		for (int i = 0; i < last; i += 1) {
			String segment = path[i];
			JSONObject nextTarget = target.getJSONObject(segment);
			if (nextTarget == null) {
				nextTarget = new JSONObject();
				target.put(segment, nextTarget);
			}
			target = nextTarget;
		}
		target.put(path[last], value);
		return jsonObject;
	}
242982
public @Nonnull JsonBuilder putArray(String key, @Nonnull Number... values) {
        JsonArray jjArray = new JsonArray();
        for (Number number : values) {
            jjArray.add(primitive(number));
        }
        object.put(key, jjArray);
        return this;
    }
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.");
    }
  }
688766
public static <T> JsonObjectBase buildObjectSuccess(String key, T value) {

        JsonObject json = new JsonObject();
        json.addData(key, value);

        LOG.info(json.toString());

        return json;
    }
507678
private void addPendingChange(String key, JsonValue value) {
        if (this.pendingChanges == null) {
            this.pendingChanges = new JsonObject();
        }

        this.pendingChanges.set(key, value);
    }
1178228
public JSONObject putOnce(String key, Object value) throws JSONException {
		if (key != null && value != null) {
			if (rawHashMap.containsKey(key)) {
				throw new JSONException("Duplicate key \"{}\"", key);
			}
			this.put(key, value);
		}
		return this;
	}
538461
protected void setJsonValue(JsonObjectBuilder builder, T value) {
    // I don't like this - there should really be a way to construct a disconnected JSONValue...
    if (value instanceof Boolean) {
      builder.add("value", (Boolean) value);
    } else if (value instanceof Double) {
      builder.add("value", (Double) value);
    } else if (value instanceof Integer) {
      builder.add("value", (Integer) value);
    } else if (value instanceof Long) {
      builder.add("value", (Long) value);
    } else if (value instanceof BigInteger) {
      builder.add("value", (BigInteger) value);
    } else if (value instanceof BigDecimal) {
      builder.add("value", (BigDecimal) value);
    } else if (value == null) {
      builder.addNull("value");
    } else {
      builder.add("value", value.toString());
    }
  }