fix(serialize-json): port comment post processing from xml to remove empty comments

This commit is contained in:
Johannes Frohnmeyer 2024-04-20 15:19:49 +02:00
parent 30f18ecef9
commit 0f8a549495
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 5 additions and 3 deletions

View File

@ -183,9 +183,11 @@ public class JsonWriter extends SerializeWriter<IOException, JsonWriter> impleme
if (!deferredComments.isEmpty()) {
if (newline.isEmpty()) {
out.append("/* ")
.append(String.join(" / ", deferredComments)
.replace("*/", "#/"))
.append(" */");
.append(String.join(" / ", deferredComments.stream()
.filter(s -> s != null && !s.isBlank())
.map(s -> s.replace("/*", "#/"))
.toList())
).append(" */");
} else {
boolean first = true;
for (String s : deferredComments) {