Skip to content

Commit a490ebd

Browse files
committed
add isEmpty and isNotEmpty methods
1 parent 3c1535d commit a490ebd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

JSONObject.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,24 @@ public int length() {
963963
return this.map.size();
964964
}
965965

966+
/**
967+
* Check if JSONObject is empty.
968+
*
969+
* @return true if JSONObject is empty, otherwise false.
970+
*/
971+
public boolean isEmpty() {
972+
return map.isEmpty();
973+
}
974+
975+
/**
976+
* Check if JSONObject is not empty.
977+
*
978+
* @return true if JSONObject is not empty, otherwise false.
979+
*/
980+
public boolean isNotEmpty() {
981+
return !map.isEmpty();
982+
}
983+
966984
/**
967985
* Produce a JSONArray containing the names of the elements of this
968986
* JSONObject.

0 commit comments

Comments
 (0)