Skip to content

Commit

Permalink
chore(stleary#887): clean up parsedUnquotedText implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
rikkarth committed Apr 23, 2024
1 parent 7cc1948 commit ce13ebd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/org/json/JSONTokener.java
Expand Up @@ -521,17 +521,17 @@ private Object parsedUnquotedText(char c, boolean strictMode) {
throw this.syntaxError("Missing value");
}

if (strictMode) {
Object stringToVal = JSONObject.stringToValue(string);
Object stringToValue = JSONObject.stringToValue(string);

if (stringToVal instanceof Number || stringToVal instanceof Boolean) {
return stringToVal;
}
return strictMode ? getValidNumberOrBooleanFromObject(stringToValue) : stringToValue;
}

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

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

/**
Expand Down

0 comments on commit ce13ebd

Please sign in to comment.