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; }