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
|
@ -810,11 +810,10 @@ public class JSONObject {
|
|||
* @return An array of field names, or null if there are no names.
|
||||
*/
|
||||
public static String[] getNames(JSONObject jo) {
|
||||
int length = jo.length();
|
||||
if (length == 0) {
|
||||
if (jo.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return jo.keySet().toArray(new String[length]);
|
||||
return jo.keySet().toArray(new String[jo.length()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -972,15 +971,6 @@ public class JSONObject {
|
|||
return map.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if JSONObject is not empty.
|
||||
*
|
||||
* @return true if JSONObject is not empty, otherwise false.
|
||||
*/
|
||||
public boolean isNotEmpty() {
|
||||
return !map.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce a JSONArray containing the names of the elements of this
|
||||
* JSONObject.
|
||||
|
@ -1966,7 +1956,7 @@ public class JSONObject {
|
|||
}
|
||||
|
||||
public static Writer quote(String string, Writer w) throws IOException {
|
||||
if (string == null || string.length() == 0) {
|
||||
if (string == null || string.isEmpty()) {
|
||||
w.write("\"\"");
|
||||
return w;
|
||||
}
|
||||
|
@ -2245,7 +2235,7 @@ public class JSONObject {
|
|||
* If any of the values are non-finite numbers.
|
||||
*/
|
||||
public JSONArray toJSONArray(JSONArray names) throws JSONException {
|
||||
if (names == null || names.length() == 0) {
|
||||
if (names == null || names.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
JSONArray ja = new JSONArray();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue