Skip to content

Manually override NewLine character? #746

Closed
@polterguy

Description

@polterguy
Contributor

Can I override what newline character(s) the library is generating as it is creating YAML? I have the following code.

// Converting to JSON object.
var expConverter = new ExpandoObjectConverter();
dynamic deserializedObject = JsonConvert.DeserializeObject<ExpandoObject>(someJsonStringHere, expConverter);

// Converting to YAML.
var serializer = new SerializerBuilder().Build();
var yaml = serializer.Serialize(deserializedObject);

I want the library to always output CR/LF, regardless of what operating system I am on. Is this possible?

Activity

EdwardCooke

EdwardCooke commented on Nov 28, 2022

@EdwardCooke
Collaborator

Right now, no. It shouldn’t be hard to implement though. We’re always willing to accept pull requests with bug fixes and additional features. If I get time I can also work on it.

added a commit that references this issue on Nov 29, 2022
polterguy

polterguy commented on Nov 29, 2022

@polterguy
ContributorAuthor

Let me know if it's acceptable. When you create a release with this, do you mind just commenting here to let me know? I kind of need this feature in our own stuff ...

I made sure it's using Environment.NewLine by default, and all tests are passing ...

EdwardCooke

EdwardCooke commented on Nov 30, 2022

@EdwardCooke
Collaborator

I’ll take a look at it later today or tonight.

polterguy

polterguy commented on Nov 30, 2022

@polterguy
ContributorAuthor

Thx

EdwardCooke

EdwardCooke commented on Dec 1, 2022

@EdwardCooke
Collaborator

Got the build started again, just a 403 error to work though. I think the token is expired for talking to github, which I can't fix. @aaubry will need to do that.

aaubry

aaubry commented on Dec 1, 2022

@aaubry
Owner

I'll have a look later.

EdwardCooke

EdwardCooke commented on Dec 8, 2022

@EdwardCooke
Collaborator

I'm going to close this since the PR is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @aaubry@polterguy@EdwardCooke

        Issue actions

          Manually override NewLine character? · Issue #746 · aaubry/YamlDotNet