Put a key/value pair in the JSONObject. If the value is null, 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,
(String key, Object value)
| 1317 | * or if the key is null. |
| 1318 | */ |
| 1319 | public JSONObject put(String key, Object value) { |
| 1320 | String pooled; |
| 1321 | if (key == null) { |
| 1322 | throw new RuntimeException("Null key."); |
| 1323 | } |
| 1324 | if (value != null) { |
| 1325 | testValidity(value); |
| 1326 | pooled = (String)keyPool.get(key); |
| 1327 | if (pooled == null) { |
| 1328 | if (keyPool.size() >= keyPoolSize) { |
| 1329 | keyPool = new HashMap<>(keyPoolSize); |
| 1330 | } |
| 1331 | keyPool.put(key, key); |
| 1332 | } else { |
| 1333 | key = pooled; |
| 1334 | } |
| 1335 | this.map.put(key, value); |
| 1336 | } else { |
| 1337 | this.remove(key); |
| 1338 | } |
| 1339 | return this; |
| 1340 | } |
| 1341 | |
| 1342 | |
| 1343 | /** |
no test coverage detected