-
-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to allow use of platform-linefeed (YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS
)
#84
Comments
Generator uses SnakeYAML defaults so this is not conscious definition. I actually do not know what YAML specs says: I assume it probably allows multiple styles of linefeeds just like JSON and XML. I would be open to having an option to change behavior: being an API change, it needs to go in Jackson 3.0 however. One challenge there is this: it is easy to add on/off kinds of things ( |
Thanks for the quick reply!
Correct. The YAML spec allows four different "generic line breaks", including CRLF for Windows and LF for Unix.
The behaviour I expect from the serializer is that it outputs textual data with line endings consistent with that platform it's running on, by default, but should allow overriding to a specific line ending. I think this is the least-surprising choice (between that and defaulting to LF), and indeed, is the design choice that's already present because of FasterXML/jackson-databind#585 so at least making that change would be internally consistent.
Would you accept a PR to add a new enumeration value to
To not break existing clients, the default value of |
YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS
)
Forgot to close, was included in 2.9.6. |
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
usesDumperOptions
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
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?
The text was updated successfully, but these errors were encountered: