Skip to content

Commit ce13ebd

Browse files
author
rikkarth
committed
chore(stleary#887): clean up parsedUnquotedText implementation
1 parent 7cc1948 commit ce13ebd

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎src/main/java/org/json/JSONTokener.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -521,17 +521,17 @@ private Object parsedUnquotedText(char c, boolean strictMode) {
521521
throw this.syntaxError("Missing value");
522522
}
523523

524-
if (strictMode) {
525-
Object stringToVal = JSONObject.stringToValue(string);
524+
Object stringToValue = JSONObject.stringToValue(string);
526525

527-
if (stringToVal instanceof Number || stringToVal instanceof Boolean) {
528-
return stringToVal;
529-
}
526+
return strictMode ? getValidNumberOrBooleanFromObject(stringToValue) : stringToValue;
527+
}
530528

531-
throw new JSONException(String.format("Value is not surrounded by quotes: %s", string));
529+
private Object getValidNumberOrBooleanFromObject(Object value) {
530+
if (value instanceof Number || value instanceof Boolean) {
531+
return value;
532532
}
533533

534-
return JSONObject.stringToValue(string);
534+
throw new JSONException(String.format("Value is not surrounded by quotes: %s", value));
535535
}
536536

537537
/**

0 commit comments

Comments
 (0)