Skip to content

Commit 19d7164

Browse files
woosung1223philwebb
authored andcommitted
Refactor BasicJsonParser to use enhanced switch
See gh-42487
1 parent 54dcd98 commit 19d7164

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,12 @@ private List<String> tokenize(String json) {
137137
inEscape = false;
138138
continue;
139139
}
140-
if (current == '{') {
141-
inObject++;
142-
}
143-
if (current == '}') {
144-
inObject--;
145-
}
146-
if (current == '[') {
147-
inList++;
148-
}
149-
if (current == ']') {
150-
inList--;
151-
}
152-
if (current == '"') {
153-
inValue = !inValue;
140+
switch (current) {
141+
case '{' -> inObject++;
142+
case '}' -> inObject--;
143+
case '[' -> inList++;
144+
case ']' -> inList--;
145+
case '"' -> inValue = !inValue;
154146
}
155147
if (current == ',' && inObject == 0 && inList == 0 && !inValue) {
156148
list.add(build.toString());

0 commit comments

Comments
 (0)