diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index d66b5a7e..f936a6f6 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -21,3 +21,8 @@ Fabrice Delhoste (spifd@github) * Reported #74 (properties): `JavaPropsMapper` issue deserializing multiple byte array properties (2.9.5) +Thomas Hauk (thauk-copperleaf@github) + +* Contibuted #84 (yaml): Add option to allow use of platform-linefeed + (`YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS`) + (2.9.6) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 940bcade..162b1b12 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,12 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.9.6 (not yet released) + +#84 (yaml): Add option to allow use of platform-linefeed + (`YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS`) + (contributed by Thomas H) + 2.9.5 (26-Mar-2018) #74 (properties): `JavaPropsMapper` issue deserializing multiple byte array properties 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 03739bf4..8e47a469 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 @@ -113,7 +113,18 @@ public enum Feature implements FormatFeature // since 2.9 * * @since 2.9 */ - INDENT_ARRAYS(false) + INDENT_ARRAYS(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. + * If disabled, Unix linefeed ({@code \n}) will be used. + *
+ * Default value is `false` for backwards compatibility. + * + * @since 2.9.6 + */ + USE_PLATFORM_LINE_BREAKS(false), ; protected final boolean _defaultState; @@ -266,6 +277,10 @@ protected DumperOptions buildDumperOptions(int jsonFeatures, int yamlFeatures, opt.setIndicatorIndent(1); opt.setIndent(2); } + // 14-May-2018: [dataformats-text#84] allow use of platform linefeed + if (Feature.USE_PLATFORM_LINE_BREAKS.enabledIn(_formatFeatures)) { + opt.setLineBreak(DumperOptions.LineBreak.getPlatformLineBreak()); + } return opt; } diff --git a/yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/ser/GeneratorFeatureTest.java b/yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/ser/GeneratorFeatureTest.java index 7e04023e..f360d874 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/ser/GeneratorFeatureTest.java +++ b/yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/ser/GeneratorFeatureTest.java @@ -7,7 +7,6 @@ import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase; import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature; public class GeneratorFeatureTest extends ModuleTestBase {