1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

changed all method signatures containing collections and maps to accept

wildcard generic types, e.g. Collection<?> instead of
Collection<Object>. This was proposed by other pull requests (#111,
#112) already. Consider this commit as merge with #111 and #112.

JSONArray:
	- put(Collection<?> value) {...}
	- put(Map<String, ?> value) {...}
	- put(int index, Collection<?> value) throws JSONException {...}
	- put(int index, Map<String, ?> value) throws JSONException {...}

JSONObject:
	- put(String key, Collection<?> value) throws JSONException {...}
	- put(String key, Map<String, ?> value) throws JSONException {...}


Changed all code affected by new JSONObject and JSONArray constructors:
	
JSONObject:
	- valueToString(Object value) throws JSONException {
		- value instanceof Map
		- value instanceof Collection
	  }
	- wrap(Object object) {
		- value instanceof Map
		- value instanceof Collection
	  }
	- writeValue(Writer writer, Object value,
			 int indentFactor, int indent){
        - value instanceof Map
        - value instanceof Collection
      }
This commit is contained in:
Lukas Treyer 2015-10-11 11:20:08 +02:00
parent 0afd26623c
commit 409eb9f292
2 changed files with 13 additions and 14 deletions

View file

@ -746,7 +746,7 @@ public class JSONArray implements Iterable<Object> {
* A Collection value.
* @return this.
*/
public JSONArray put(Collection<Object> value) {
public JSONArray put(Collection<?> value) {
this.put(new JSONArray(value));
return this;
}
@ -799,7 +799,7 @@ public class JSONArray implements Iterable<Object> {
* A Map value.
* @return this.
*/
public JSONArray put(Map<String, Object> value) {
public JSONArray put(Map<String, ?> value) {
this.put(new JSONObject(value));
return this;
}
@ -848,7 +848,7 @@ public class JSONArray implements Iterable<Object> {
* @throws JSONException
* If the index is negative or if the value is not finite.
*/
public JSONArray put(int index, Collection<Object> value) throws JSONException {
public JSONArray put(int index, Collection<?> value) throws JSONException {
this.put(index, new JSONArray(value));
return this;
}
@ -920,7 +920,7 @@ public class JSONArray implements Iterable<Object> {
* If the index is negative or if the the value is an invalid
* number.
*/
public JSONArray put(int index, Map<String, Object> value) throws JSONException {
public JSONArray put(int index, Map<String, ?> value) throws JSONException {
this.put(index, new JSONObject(value));
return this;
}