This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 2daa94765a Add newline to json Arrays in hop-config, fixes #5769
(#5782)
2daa94765a is described below
commit 2daa94765ad78aad1d00fc445d3c0b2a08f51763
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Mon Oct 6 11:50:27 2025 +0200
Add newline to json Arrays in hop-config, fixes #5769 (#5782)
---
.../java/org/apache/hop/core/config/ConfigFileSerializer.java | 9 ++++++++-
core/src/main/java/org/apache/hop/core/json/HopJson.java | 4 ++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git
a/core/src/main/java/org/apache/hop/core/config/ConfigFileSerializer.java
b/core/src/main/java/org/apache/hop/core/config/ConfigFileSerializer.java
index 9e8b0b0032..7dd92341ae 100644
--- a/core/src/main/java/org/apache/hop/core/config/ConfigFileSerializer.java
+++ b/core/src/main/java/org/apache/hop/core/config/ConfigFileSerializer.java
@@ -18,6 +18,8 @@
package org.apache.hop.core.config;
import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.core.util.DefaultIndenter;
+import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.InputStream;
import java.io.OutputStream;
@@ -34,7 +36,12 @@ public class ConfigFileSerializer implements
IHopConfigSerializer {
public void writeToFile(String filename, Map<String, Object> configMap)
throws HopException {
try {
ObjectMapper objectMapper = HopJson.newMapper();
- String niceJson =
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(configMap);
+
+ // Add option to indent arrays in the pretty printer
+ DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
+ prettyPrinter.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE);
+
+ String niceJson =
objectMapper.writer(prettyPrinter).writeValueAsString(configMap);
// Write to a new new file...
//
diff --git a/core/src/main/java/org/apache/hop/core/json/HopJson.java
b/core/src/main/java/org/apache/hop/core/json/HopJson.java
index 4df41f6625..bce33b6f95 100644
--- a/core/src/main/java/org/apache/hop/core/json/HopJson.java
+++ b/core/src/main/java/org/apache/hop/core/json/HopJson.java
@@ -29,8 +29,8 @@ public class HopJson {
*/
public static final ObjectMapper newMapper() {
ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
false);
- objectMapper.configure(SerializationFeature.INDENT_OUTPUT, false);
+ objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+ objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
return objectMapper;
}
}