mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
change length comparison to isEmpty method
This commit is contained in:
parent
a490ebdb78
commit
05074386d3
5 changed files with 25 additions and 25 deletions
|
@ -1352,7 +1352,7 @@ public class JSONArray implements Iterable<Object> {
|
|||
* If any of the names are null.
|
||||
*/
|
||||
public JSONObject toJSONObject(JSONArray names) throws JSONException {
|
||||
if (names == null || names.length() == 0 || this.length() == 0) {
|
||||
if (names == null || names.isEmpty() || this.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
JSONObject jo = new JSONObject(names.length());
|
||||
|
@ -1528,4 +1528,14 @@ public class JSONArray implements Iterable<Object> {
|
|||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if JSONArray is empty.
|
||||
*
|
||||
* @return true if JSONArray is empty, otherwise false.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return myArrayList.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue