You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by no...@apache.org on 2023/09/20 14:40:30 UTC

[solr] 01/01: indent JSON properly

This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch jira/solr16925
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 693f54ff7cdbe03b971060e8b430fe01addfb5b7
Author: noblepaul <no...@gmail.com>
AuthorDate: Thu Sep 21 00:40:07 2023 +1000

    indent JSON properly
---
 .../core/src/java/org/apache/solr/response/JacksonJsonWriter.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/solr/core/src/java/org/apache/solr/response/JacksonJsonWriter.java b/solr/core/src/java/org/apache/solr/response/JacksonJsonWriter.java
index 7a1ff5276a8..872b6ba27d8 100644
--- a/solr/core/src/java/org/apache/solr/response/JacksonJsonWriter.java
+++ b/solr/core/src/java/org/apache/solr/response/JacksonJsonWriter.java
@@ -25,11 +25,17 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.util.Arrays;
 import org.apache.solr.common.PushWriter;
 import org.apache.solr.request.SolrQueryRequest;
 
 /** A JSON ResponseWriter that uses jackson. */
 public class JacksonJsonWriter extends BinaryResponseWriter {
+  private static final char[] indentChars = new char[81];
+
+  static {
+    Arrays.fill(indentChars, ' ');
+  }
 
   protected final JsonFactory jsonfactory;
   protected static final PrettyPrinter pretty =
@@ -199,7 +205,7 @@ public class JacksonJsonWriter extends BinaryResponseWriter {
 
     @Override
     public void indent() throws IOException {
-      // do nothing
+      gen.writeRaw(indentChars, 0, Math.min((level() << 1) + 1, indentChars.length));
     }
 
     @Override