code: public JSONObject put(String key, Object value) throws JSONException {
          if (key == null) {
              throw new NullPointerException("Null key.");
          }
          if (value != null) {
              testValidity(value);
              this.map.put(key, value);
          } else {
              this.remove(key);
          }
          return this;
      }
docs: Put a key/value pair in the JSONObject. If the value is <code>null</code>, then the
  key will be removed from the JSONObject if it is present.
  
  @param key
  A key string.
  @param value
  An object which is the value. It should be of one of these
  types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
  String, or the JSONObject.NULL object.
  @return this.
  @throws JSONException
  If the value is non-finite number.
  @throws NullPointerException
  If the key is <code>null</code>.