I would like to be able to preserve indentation when deserializing YAML to a Java object. If this is my YAML:
description: |
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of
type and scrambled it to make a type specimen book.
When I deserialize it, the description
in my Java object looks like this:
description: "Lorem Ipsum is simply dummy text of the printing and typesetting industry.\n
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,\nwhen an unknown printer took a galley of\ntype and scrambled it to make a type specimen book."
As you can see it preserves the new lines, but not the trailing white-spaces in each line. This is how my Jackson mapper is configured:
YAMLFactory yamlFactory = new YAMLFactory()
.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
.enable(YAMLGenerator.Feature.MINIMIZE_QUOTES)
.enable(YAMLGenerator.Feature.INDENT_ARRAYS);
ObjectMapper objectMapper = new ObjectMapper(yamlFactory)
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
Is there any way that I can configure it to also include indendation in each line?