Skip to content

Commit ff897a3

Browse files
committed
Restructured switch statements to if else for more readability.
1 parent 2c6082a commit ff897a3

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,25 +454,28 @@ public String nextTo(String delimiters) throws JSONException {
454454
*/
455455
public Object nextValue() throws JSONException {
456456
char c = this.nextClean();
457-
switch (c) {
458-
case '{':
457+
458+
if (c == '{') {
459459
this.back();
460460
try {
461461
return new JSONObject(this, jsonParserConfiguration);
462462
} catch (StackOverflowError e) {
463463
throw new JSONException("JSON Array or Object depth too large to process.", e);
464464
}
465-
case '[':
465+
466+
} else if (c == '[') {
466467
this.back();
467468
try {
468469
return new JSONArray(this, jsonParserConfiguration);
469470
} catch (StackOverflowError e) {
470471
throw new JSONException("JSON Array or Object depth too large to process.", e);
471472
}
472473
}
474+
473475
return nextSimpleValue(c);
474476
}
475477

478+
476479
Object nextSimpleValue(char c) {
477480
String string;
478481

@@ -482,9 +485,8 @@ Object nextSimpleValue(char c) {
482485
c == '\'') {
483486
throw this.syntaxError("Strict mode error: Single quoted strings are not allowed");
484487
}
485-
switch (c) {
486-
case '"':
487-
case '\'':
488+
489+
if (c == '"' || c == '\'') {
488490
return this.nextString(c);
489491
}
490492

0 commit comments

Comments
 (0)