Merge pull request #42487 from woosung1223

* pr/42487:
  Refactor BasicJsonParser to use enhanced switch

Closes gh-42487
This commit is contained in:
Phillip Webb
2024-10-02 13:40:37 -07:00

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());