From d1a8755ca79306d2662fd120b074d8b8aae396dd Mon Sep 17 00:00:00 2001 From: Thomas Hauk Date: Mon, 7 May 2018 18:01:33 -0700 Subject: [PATCH] Add USE_PLATFORM_LINE_BREAKS option to YAMLGenerator.Feature --- .../jackson/dataformat/yaml/YAMLGenerator.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java b/yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java index c86f5e75..4fe74b02 100644 --- a/yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java +++ b/yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java @@ -91,6 +91,14 @@ public enum Feature implements FormatFeature */ LITERAL_BLOCK_STYLE(false), + /** + * Option passed to SnakeYAML that determines if the line breaks used for + * serialization should be same as what the default is for current platform. + *

+ * Default value is `false` for backwards compatibility + */ + USE_PLATFORM_LINE_BREAKS(false), + /** * Feature enabling of which adds indentation for array entry generation * (default indentation being 2 spaces). @@ -251,6 +259,9 @@ protected DumperOptions buildDumperOptions(int jsonFeatures, int yamlFeatures, opt.setIndicatorIndent(1); opt.setIndent(2); } + if (Feature.USE_PLATFORM_LINE_BREAKS.enabledIn(_formatFeatures)) { + opt.setLineBreak(DumperOptions.LineBreak.getPlatformLineBreak()); + } return opt; }