We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 18af90c commit 6a11334Copy full SHA for 6a11334
src/main/java/org/json/JSONObject.java
@@ -3529,8 +3529,8 @@ public Map create() {
3529
private <E extends Enum<E>> E stringToEnum(Class<?> enumClass, String value) throws JSONException {
3530
try {
3531
@SuppressWarnings("unchecked")
3532
- Method valueOfMethod = enumClass.getMethod("valueOf", String.class);
3533
- return (E) valueOfMethod.invoke(null, value);
+ Class<E> enumType = (Class<E>) enumClass;
+ return Enum.valueOf(enumType, value);
3534
} catch (Exception e) {
3535
throw new JSONException("Failed to convert string to enum: " + value + " for " + enumClass.getName(), e);
3536
}
0 commit comments