com.marklogic.hub.util.JacksonUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marklogic-data-hub Show documentation
Show all versions of marklogic-data-hub Show documentation
Library for Creating an Operational Data Hub on MarkLogic
package com.marklogic.hub.util;
import com.fasterxml.jackson.core.util.DefaultIndenter;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
/**
* Contains convenience methods for when working with the com.fasterxml.jackson library.
*/
public abstract class JacksonUtil {
/**
* Convenient for print JSON nodes with arrays that have potentially many values, such that seeing them all on
* one line would be very difficult to read.
*
* @return
*/
public static ObjectWriter newWriterWithSeparateLinesForArrayValues() {
ObjectMapper mapper = new ObjectMapper();
DefaultPrettyPrinter printer = new DefaultPrettyPrinter();
printer.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE);
mapper.setDefaultPrettyPrinter(printer);
return mapper.writerWithDefaultPrettyPrinter();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy