-
-
Notifications
You must be signed in to change notification settings - Fork 151
Description
The behaviour I expect would be for the serializer to produce output with line endings consistent with that platform it's running on, unless explicitly overriden.
I'm just wondering if this is on purpose or not?
Deeper dive:
YAMLGenerator
uses DumperOptions
from snakeyaml and overrides some settings, but does not override the line ending setting:
jackson-dataformats-text/yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java
Lines 231 to 255 in a0f5c80
protected DumperOptions buildDumperOptions(int jsonFeatures, int yamlFeatures, | |
org.yaml.snakeyaml.DumperOptions.Version version) | |
{ | |
DumperOptions opt = new DumperOptions(); | |
// would we want canonical? | |
if (Feature.CANONICAL_OUTPUT.enabledIn(_formatFeatures)) { | |
opt.setCanonical(true); | |
} else { | |
opt.setCanonical(false); | |
// if not, MUST specify flow styles | |
opt.setDefaultFlowStyle(FlowStyle.BLOCK); | |
} | |
// split-lines for text blocks? | |
opt.setSplitLines(Feature.SPLIT_LINES.enabledIn(_formatFeatures)); | |
// array indentation? | |
if (Feature.INDENT_ARRAYS.enabledIn(_formatFeatures)) { | |
// But, wrt [dataformats-text#34]: need to set both to diff values to work around bug | |
// (otherwise indentation level is "invisible". Note that this should NOT be necessary | |
// but is needed up to at least SnakeYAML 1.18. | |
// Also looks like all kinds of values do work, except for both being 2... weird. | |
opt.setIndicatorIndent(1); | |
opt.setIndent(2); | |
} | |
return opt; | |
} |
And since DumperOptions
has the following default:
private LineBreak lineBreak = LineBreak.UNIX;
That results in output having Unix line endings, regardless of platform.
Alternatively, can you tell me how to produce YAML with platform-specific line endings?