Skip to content

Commit b2e65f6

Browse files
committed
Polish
1 parent 0a9f6a7 commit b2e65f6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,7 @@ else if (value instanceof WritableJson writableJson) {
115115
throw new UncheckedIOException(ex);
116116
}
117117
}
118-
else if (value instanceof Path p) {
119-
writeString(p.toString());
120-
}
121-
else if (value instanceof Iterable<?> iterable) {
118+
else if (value instanceof Iterable<?> iterable && canWriteAsArray(iterable)) {
122119
writeArray(iterable::forEach);
123120
}
124121
else if (ObjectUtils.isArray(value)) {
@@ -135,6 +132,10 @@ else if (value instanceof Number || value instanceof Boolean) {
135132
}
136133
}
137134

135+
private <V> boolean canWriteAsArray(Iterable<?> iterable) {
136+
return !(iterable instanceof Path);
137+
}
138+
138139
/**
139140
* Start a new {@link Series} (JSON object or array).
140141
* @param series the series to start

0 commit comments

Comments
 (0)