List of usage examples for com.fasterxml.jackson.core.util DefaultIndenter SYSTEM_LINEFEED_INSTANCE
DefaultIndenter SYSTEM_LINEFEED_INSTANCE
To view the source code for com.fasterxml.jackson.core.util DefaultIndenter SYSTEM_LINEFEED_INSTANCE.
Click Source Link
From source file:com.mirth.connect.util.MirthJsonUtil.java
public static String prettyPrint(String input) { ObjectMapper mapper = new ObjectMapper(new JsonFactory()); mapper.enable(SerializationFeature.INDENT_OUTPUT); try {// ww w . j a v a2 s. c om // Modified Jackson's default pretty printer to separate each array element onto its own line DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter(); prettyPrinter.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE); JsonNode json = mapper.readTree(input); return mapper.writer(prettyPrinter).writeValueAsString(json); } catch (Exception e) { logger.warn("Error pretty printing json.", e); } return input; }