From b2e65f665aeaf991242272d13431bc2de742deff Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 22 Apr 2025 19:51:06 -0700 Subject: [PATCH] Polish --- .../org/springframework/boot/json/JsonValueWriter.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/JsonValueWriter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/JsonValueWriter.java index 1d8046a0f60..a48c304f4c9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/JsonValueWriter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/JsonValueWriter.java @@ -115,10 +115,7 @@ class JsonValueWriter { throw new UncheckedIOException(ex); } } - else if (value instanceof Path p) { - writeString(p.toString()); - } - else if (value instanceof Iterable iterable) { + else if (value instanceof Iterable iterable && canWriteAsArray(iterable)) { writeArray(iterable::forEach); } else if (ObjectUtils.isArray(value)) { @@ -135,6 +132,10 @@ class JsonValueWriter { } } + private boolean canWriteAsArray(Iterable iterable) { + return !(iterable instanceof Path); + } + /** * Start a new {@link Series} (JSON object or array). * @param series the series to start