mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-08 11:34:43 +08:00
add validity check for JSONObject constructors
* fixes #713 * document JSONException in JavaDoc * remove unused Comparable<T> boundary to reuse GenericBean in test
This commit is contained in:
@@ -283,6 +283,7 @@ public class JSONObject {
|
||||
}
|
||||
final Object value = e.getValue();
|
||||
if (value != null) {
|
||||
testValidity(value);
|
||||
this.map.put(String.valueOf(e.getKey()), wrap(value));
|
||||
}
|
||||
}
|
||||
@@ -346,6 +347,8 @@ public class JSONObject {
|
||||
* @param bean
|
||||
* An object that has getter methods that should be used to make
|
||||
* a JSONObject.
|
||||
* @throws JSONException
|
||||
* If a getter returned a non-finite number.
|
||||
*/
|
||||
public JSONObject(Object bean) {
|
||||
this();
|
||||
@@ -1691,6 +1694,8 @@ public class JSONObject {
|
||||
*
|
||||
* @param bean
|
||||
* the bean
|
||||
* @throws JSONException
|
||||
* If a getter returned a non-finite number.
|
||||
*/
|
||||
private void populateMap(Object bean) {
|
||||
populateMap(bean, Collections.newSetFromMap(new IdentityHashMap<Object, Boolean>()));
|
||||
@@ -1726,6 +1731,7 @@ public class JSONObject {
|
||||
|
||||
objectsRecord.add(result);
|
||||
|
||||
testValidity(result);
|
||||
this.map.put(key, wrap(result, objectsRecord));
|
||||
|
||||
objectsRecord.remove(result);
|
||||
|
Reference in New Issue
Block a user