Closed devatherock closed 3 years ago
Setting jackson.serialization.indent-output to true does not indent arrays. Need additional configuration to enable array indentation.
jackson.serialization.indent-output
true
@Singleton static class ObjectMapperBeanEventListener implements BeanCreatedEventListener<ObjectMapper> { @Override public ObjectMapper onCreated(BeanCreatedEvent<ObjectMapper> event) { final ObjectMapper objectMapper = event.getBean(); DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter(); prettyPrinter.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE); objectMapper.setDefaultPrettyPrinter(prettyPrinter); return objectMapper; } }
References: https://stackoverflow.com/questions/53195071/how-to-configure-jackson-to-use-snake-case-in-micronaut https://stackoverflow.com/questions/17411586/jackson-json-not-formatting-correctly/17415099 https://stackoverflow.com/questions/28256852/what-is-the-simplest-way-to-configure-the-indentation-spacing-on-a-jackson-objec https://www.endpoint.com/blog/2020/03/17/serialization-issues-spring-rest
Setting
jackson.serialization.indent-output
totrue
does not indent arrays. Need additional configuration to enable array indentation.References: https://stackoverflow.com/questions/53195071/how-to-configure-jackson-to-use-snake-case-in-micronaut https://stackoverflow.com/questions/17411586/jackson-json-not-formatting-correctly/17415099 https://stackoverflow.com/questions/28256852/what-is-the-simplest-way-to-configure-the-indentation-spacing-on-a-jackson-objec https://www.endpoint.com/blog/2020/03/17/serialization-issues-spring-rest