diff --git a/src/main/java/org/json/JSONArray.java b/src/main/java/org/json/JSONArray.java index 338177c..5c34662 100644 --- a/src/main/java/org/json/JSONArray.java +++ b/src/main/java/org/json/JSONArray.java @@ -567,6 +567,14 @@ public class JSONArray implements Iterable { return this.myArrayList.size(); } + /** + * Removes all of the elements from this JSONArray. + * The JSONArray will be empty after this call returns. + */ + public void clear() { + return this.map.clear(); + } + /** * Get the optional object value associated with an index. * diff --git a/src/main/java/org/json/JSONObject.java b/src/main/java/org/json/JSONObject.java index b838b8e..150d84c 100644 --- a/src/main/java/org/json/JSONObject.java +++ b/src/main/java/org/json/JSONObject.java @@ -973,6 +973,14 @@ public class JSONObject { return this.map.size(); } + /** + * Removes all of the elements from this JSONObject. + * The JSONObject will be empty after this call returns. + */ + public void clear() { + return this.map.clear(); + } + /** * Check if JSONObject is empty. *