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
(String key, Object value)
| 1110 | * @throws JSONException if the key is a duplicate |
| 1111 | */ |
| 1112 | public JSONObject putOnce(String key, Object value) throws JSONException { |
| 1113 | if (key != null && value != null) { |
| 1114 | if (opt(key) != null) { |
| 1115 | throw new JSONException("Duplicate key \"" + key + "\""); |
| 1116 | } |
| 1117 | put(key, value); |
| 1118 | } |
| 1119 | return this; |
| 1120 | } |
| 1121 | |
| 1122 | |
| 1123 | /** |
no test coverage detected