diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java index 38a66f9fa8c6..bc0ac4ce8e3a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java @@ -137,20 +137,12 @@ private List tokenize(String json) { 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()); @@ -169,5 +161,4 @@ else if (current == '\\') { } return list; } - }