Refactor BasicJsonParser to use enhanced switch

See gh-42487
This commit is contained in:
teo
2024-10-01 15:33:20 +09:00
committed by Phillip Webb
parent 54dcd9894c
commit 19d7164696

View File

@@ -137,20 +137,12 @@ public class BasicJsonParser extends AbstractJsonParser {
inEscape = false;
continue;
}
if (current == '{') {
inObject++;
}
if (current == '}') {
inObject--;
}
if (current == '[') {
inList++;
}
if (current == ']') {
inList--;
}
if (current == '"') {
inValue = !inValue;
switch (current) {
case '{' -> inObject++;
case '}' -> inObject--;
case '[' -> inList++;
case ']' -> inList--;
case '"' -> inValue = !inValue;
}
if (current == ',' && inObject == 0 && inList == 0 && !inValue) {
list.add(build.toString());