Skip to content

Commit

Permalink
Adding comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sk02241994 committed Dec 24, 2023
1 parent a73302e commit fa8ad5d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/main/java/org/json/JSONArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public JSONArray(Collection<?> collection, JSONParserConfiguration jsonParserCon
* @param collection
* A Collection.
* @param recursionDepth
* variable to keep the count of how nested the object creation is happening.
* Variable for tracking the count of nested object creations.
* @param jsonParserConfiguration
* Configuration object for the JSON parser
*/
Expand Down Expand Up @@ -1829,8 +1829,7 @@ public boolean isEmpty() {
* {@code true} to call {@link JSONObject#wrap(Object)} for each item,
* {@code false} to add the items directly
* @param recursionDepth
* variable to keep the count of how nested the object creation is happening.
*
* Variable for tracking the count of nested object creations.
*/
private void addAll(Collection<?> collection, boolean wrap, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) {
this.myArrayList.ensureCapacity(this.myArrayList.size() + collection.size());
Expand Down Expand Up @@ -1894,7 +1893,7 @@ private void addAll(Object array, boolean wrap) throws JSONException {
* {@code true} to call {@link JSONObject#wrap(Object)} for each item,
* {@code false} to add the items directly
* @param recursionDepth
* variable to keep the count of how nested the object creation is happening.
* Variable for tracking the count of nested object creations.
*/
private void addAll(Object array, boolean wrap, int recursionDepth) {
addAll(array, wrap, recursionDepth, new JSONParserConfiguration());
Expand All @@ -1910,7 +1909,7 @@ private void addAll(Object array, boolean wrap, int recursionDepth) {
* {@code true} to call {@link JSONObject#wrap(Object)} for each item,
* {@code false} to add the items directly
* @param recursionDepth
* Variable to keep the count of how nested the object creation is happening.
* Variable for tracking the count of nested object creations.
* @param jsonParserConfiguration
* Variable to pass parser custom configuration for json parsing.
* @throws JSONException
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/org/json/JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,23 @@ public static Object wrap(Object object) {
return wrap(object, null);
}

public static Object wrap(Object object, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) {
/**
* Wrap an object, if necessary. If the object is <code>null</code>, return the NULL
* object. If it is an array or collection, wrap it in a JSONArray. If it is
* a map, wrap it in a JSONObject. If it is a standard property (Double,
* String, et al) then it is already wrapped. Otherwise, if it comes from
* one of the java packages, turn it into a string. And if it doesn't, try
* to wrap it in a JSONObject. If the wrapping fails, then null is returned.
*
* @param object
* The object to wrap
* @param recursionDepth
* Variable for tracking the count of nested object creations.
* @param jsonParserConfiguration
* Variable to pass parser custom configuration for json parsing.
* @return The wrapped value
*/
static Object wrap(Object object, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) {
return wrap(object, null, recursionDepth, jsonParserConfiguration);
}

Expand Down

0 comments on commit fa8ad5d

Please sign in to comment.