/** * @webref jsonobject:method * @brief Sets the JSONObject value associated with a key * @param key a key string * @param value value to assign * @see JSONObject#setJSONArray(String, JSONArray) * @see JSONObject#getJSONObject(String) * @see JSONObject#getJSONArray(String) */ public JSONObject setJSONObject(String key, JSONObject value) { return put(key, value); }
/** * @webref jsonobject:method * @brief Put a key/String pair in the JSONObject * @param key a key string * @param value the value to assign * @see JSONObject#setInt(String, int) * @see JSONObject#setFloat(String, float) * @see JSONObject#setBoolean(String, boolean) */ public JSONObject setString(String key, String value) { return put(key, value); }
/** * @webref jsonobject:method * @brief Sets the JSONArray value associated with a key * @param key a key string * @param value value to assign * @see JSONObject#setJSONObject(String, JSONObject) * @see JSONObject#getJSONObject(String) * @see JSONObject#getJSONArray(String) */ public JSONObject setJSONArray(String key, JSONArray value) { return put(key, value); }
/** * @webref jsonobject:method * @brief Sets the JSONObject value associated with a key * @param key a key string * @param value value to assign * @see JSONObject#setJSONArray(String, JSONArray) * @see JSONObject#getJSONObject(String) * @see JSONObject#getJSONArray(String) */ public JSONObject setJSONObject(String key, JSONObject value) { return put(key, value); }
/** * @webref jsonobject:method * @brief Sets the JSONArray value associated with a key * @param key a key string * @param value value to assign * @see JSONObject#setJSONObject(String, JSONObject) * @see JSONObject#getJSONObject(String) * @see JSONObject#getJSONArray(String) */ public JSONObject setJSONArray(String key, JSONArray value) { return put(key, value); }
/** * @webref jsonobject:method * @brief Put a key/String pair in the JSONObject * @param key a key string * @param value the value to assign * @see JSONObject#setInt(String, int) * @see JSONObject#setFloat(String, float) * @see JSONObject#setBoolean(String, boolean) */ public JSONObject setString(String key, String value) { return put(key, value); }
/** * Put a key/boolean pair in the JSONObject. * * @webref jsonobject:method * @brief Put a key/boolean pair in the JSONObject * @param key a key string * @param value the value to assign * @return this. * @throws JSONException If the key is null. * @see JSONObject#setInt(String, int) * @see JSONObject#setFloat(String, float) * @see JSONObject#setString(String, String) */ public JSONObject setBoolean(String key, boolean value) { this.put(key, value ? Boolean.TRUE : Boolean.FALSE); return this; }
/** * Put a key/boolean pair in the JSONObject. * * @webref jsonobject:method * @brief Put a key/boolean pair in the JSONObject * @param key a key string * @param value the value to assign * @return this. * @throws RuntimeException If the key is null. * @see JSONObject#setInt(String, int) * @see JSONObject#setFloat(String, float) * @see JSONObject#setString(String, String) */ public JSONObject setBoolean(String key, boolean value) { this.put(key, value ? Boolean.TRUE : Boolean.FALSE); return this; }
/** * Put a key/double pair in the JSONObject. * * @param key A key string. * @param value A double which is the value. * @return this. * @throws RuntimeException If the key is null or if the number is NaN or infinite. */ public JSONObject setDouble(String key, double value) { this.put(key, Double.valueOf(value)); return this; }
/** * Put a key/double pair in the JSONObject. * * @param key A key string. * @param value A double which is the value. * @return this. * @throws JSONException If the key is null or if the number is invalid. */ public JSONObject setDouble(String key, double value) { this.put(key, new Double(value)); return this; }
/** * Put a key/long pair in the JSONObject. * * @param key A key string. * @param value A long which is the value. * @return this. * @throws RuntimeException If the key is null. */ public JSONObject setLong(String key, long value) { this.put(key, Long.valueOf(value)); return this; }
/** * @webref jsonobject:method * @brief Put a key/float pair in the JSONObject * @param key a key string * @param value the value to assign * @see JSONObject#setInt(String, int) * @see JSONObject#setString(String, String) * @see JSONObject#setBoolean(String, boolean) */ public JSONObject setFloat(String key, float value) { this.put(key, new Double(value)); return this; }
/** * Put a key/long pair in the JSONObject. * * @param key A key string. * @param value A long which is the value. * @return this. * @throws JSONException If the key is null. */ public JSONObject setLong(String key, long value) { this.put(key, new Long(value)); return this; }
/** * @webref jsonobject:method * @brief Put a key/float pair in the JSONObject * @param key a key string * @param value the value to assign * @throws RuntimeException If the key is null or if the number is NaN or infinite. * @see JSONObject#setInt(String, int) * @see JSONObject#setString(String, String) * @see JSONObject#setBoolean(String, boolean) */ public JSONObject setFloat(String key, float value) { this.put(key, Double.valueOf(value)); return this; }
/** * Put a key/int pair in the JSONObject. * * @webref jsonobject:method * @brief Put a key/int pair in the JSONObject * @param key a key string * @param value the value to assign * @return this. * @throws RuntimeException If the key is null. * @see JSONObject#setFloat(String, float) * @see JSONObject#setString(String, String) * @see JSONObject#setBoolean(String, boolean) */ public JSONObject setInt(String key, int value) { this.put(key, Integer.valueOf(value)); return this; }
/** * Put a key/int pair in the JSONObject. * * @webref jsonobject:method * @brief Put a key/int pair in the JSONObject * @param key a key string * @param value the value to assign * @return this. * @throws JSONException If the key is null. * @see JSONObject#setFloat(String, float) * @see JSONObject#setString(String, String) * @see JSONObject#setBoolean(String, boolean) */ public JSONObject setInt(String key, int value) { this.put(key, new Integer(value)); return this; }
/** * Put a key/value pair in the JSONObject, but only if the key and the * value are both non-null, and only if there is not already a member * with that name. * @param key * @param value * @return his. * @throws JSONException if the key is a duplicate */ private JSONObject putOnce(String key, Object value) { if (key != null && value != null) { if (this.opt(key) != null) { throw new RuntimeException("Duplicate key \"" + key + "\""); } this.put(key, value); } return this; }
/** * Put a key/value pair in the JSONObject, but only if the key and the * value are both non-null, and only if there is not already a member * with that name. * @param key * @param value * @return {@code this}. * @throws RuntimeException if the key is a duplicate, or if * {@link #put(String,Object)} throws. */ private JSONObject putOnce(String key, Object value) { if (key != null && value != null) { if (this.opt(key) != null) { throw new RuntimeException("Duplicate key \"" + key + "\""); } this.put(key, value); } return this; }