mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
Use constant.equals()
There are some equals() that are not constant.equals(variable), but variable.equals(constant)
This commit is contained in:
parent
72a1a48173
commit
e800cc349f
@ -334,13 +334,11 @@ public class JSONArray implements Iterable<Object> {
|
|||||||
*/
|
*/
|
||||||
public boolean getBoolean(int index) throws JSONException {
|
public boolean getBoolean(int index) throws JSONException {
|
||||||
Object object = this.get(index);
|
Object object = this.get(index);
|
||||||
if (object.equals(Boolean.FALSE)
|
if (Boolean.FALSE.equals(object)
|
||||||
|| (object instanceof String && ((String) object)
|
|| (object instanceof String && "false".equalsIgnoreCase((String) object))) {
|
||||||
.equalsIgnoreCase("false"))) {
|
|
||||||
return false;
|
return false;
|
||||||
} else if (object.equals(Boolean.TRUE)
|
} else if (Boolean.TRUE.equals(object)
|
||||||
|| (object instanceof String && ((String) object)
|
|| (object instanceof String && "true".equalsIgnoreCase((String) object))) {
|
||||||
.equalsIgnoreCase("true"))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
throw wrongValueFormatException(index, "boolean", object, null);
|
throw wrongValueFormatException(index, "boolean", object, null);
|
||||||
|
@ -111,7 +111,7 @@ public class JSONML {
|
|||||||
}
|
}
|
||||||
} else if (c == '[') {
|
} else if (c == '[') {
|
||||||
token = x.nextToken();
|
token = x.nextToken();
|
||||||
if (token.equals("CDATA") && x.next() == '[') {
|
if ("CDATA".equals(token) && x.next() == '[') {
|
||||||
if (ja != null) {
|
if (ja != null) {
|
||||||
ja.put(x.nextCDATA());
|
ja.put(x.nextCDATA());
|
||||||
}
|
}
|
||||||
|
@ -679,13 +679,11 @@ public class JSONObject {
|
|||||||
*/
|
*/
|
||||||
public boolean getBoolean(String key) throws JSONException {
|
public boolean getBoolean(String key) throws JSONException {
|
||||||
Object object = this.get(key);
|
Object object = this.get(key);
|
||||||
if (object.equals(Boolean.FALSE)
|
if (Boolean.FALSE.equals(object)
|
||||||
|| (object instanceof String && ((String) object)
|
|| (object instanceof String && "false".equalsIgnoreCase((String) object))) {
|
||||||
.equalsIgnoreCase("false"))) {
|
|
||||||
return false;
|
return false;
|
||||||
} else if (object.equals(Boolean.TRUE)
|
} else if (Boolean.TRUE.equals(object)
|
||||||
|| (object instanceof String && ((String) object)
|
|| (object instanceof String && "true".equalsIgnoreCase((String) object))) {
|
||||||
.equalsIgnoreCase("true"))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
throw wrongValueFormatException(key, "Boolean", object, null);
|
throw wrongValueFormatException(key, "Boolean", object, null);
|
||||||
@ -1911,7 +1909,7 @@ public class JSONObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//If the superclass is Object, no annotations will be found any more
|
//If the superclass is Object, no annotations will be found any more
|
||||||
if (c.getSuperclass().equals(Object.class))
|
if (Object.class.equals(c.getSuperclass()))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1969,7 +1967,7 @@ public class JSONObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//If the superclass is Object, no annotations will be found any more
|
//If the superclass is Object, no annotations will be found any more
|
||||||
if (c.getSuperclass().equals(Object.class))
|
if (Object.class.equals(c.getSuperclass()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -3022,7 +3020,7 @@ public class JSONObject {
|
|||||||
* @return number without leading zeros
|
* @return number without leading zeros
|
||||||
*/
|
*/
|
||||||
private static String removeLeadingZerosOfNumber(String value){
|
private static String removeLeadingZerosOfNumber(String value){
|
||||||
if (value.equals("-")){return value;}
|
if ("-".equals(value)){return value;}
|
||||||
boolean negativeFirstChar = (value.charAt(0) == '-');
|
boolean negativeFirstChar = (value.charAt(0) == '-');
|
||||||
int counter = negativeFirstChar ? 1:0;
|
int counter = negativeFirstChar ? 1:0;
|
||||||
while (counter < value.length()){
|
while (counter < value.length()){
|
||||||
|
@ -127,7 +127,7 @@ public class JSONPointer {
|
|||||||
if (pointer == null) {
|
if (pointer == null) {
|
||||||
throw new NullPointerException("pointer cannot be null");
|
throw new NullPointerException("pointer cannot be null");
|
||||||
}
|
}
|
||||||
if (pointer.isEmpty() || pointer.equals("#")) {
|
if (pointer.isEmpty() || "#".equals(pointer)) {
|
||||||
this.refTokens = Collections.emptyList();
|
this.refTokens = Collections.emptyList();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user