-
-
Notifications
You must be signed in to change notification settings - Fork 485
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
Yaml format after .Save() #339
Comments
// in: // change this to: |
I'm sorry I was unable to answer this question in a timely fashion. As you have certainly moved on to other things, I will close this issue, but feel free to reopen it if this is still an issue. |
Oh somehow I missed the previous answer. I will try it today and if it works I be happy, else I will be back here :) |
Hello, @seanfinniss answer helped that @aaubry any more advise here? Thanks, Yves |
I need to look into this. Maybe there is some information that is not being preserved. |
Any progress the past year? In my case the yaml stream emits an undesirable explicit document marker as well. Code: var mappingNode = new YamlMappingNode();
var yaml = new YamlDocument(mappingNode);
mappingNode.Add("one", "other");
var yamlStream = new YamlStream(yaml);
var buffer = new StringBuilder();
using (var writer = new StringWriter(buffer))
{
yamlStream.Save(writer, assignAnchors: false);
output.WriteLine(writer.ToString());
} Current output: one: other
... Desired output: one: other |
@cveld Try doing serialize instead. The below is F# code but it is similar to C#: let serializer = SerializerBuilder().Build();
let SaveFile (path:string) (yaml:YamlStream) =
use file = File.Open(path, FileMode.Create)
use writer = new StreamWriter(file, System.Text.Encoding.UTF8)
serializer.Serialize(writer, yaml.Documents.[0].RootNode) |
Hello,
I am new to YamlDotNet, as everyone uses it, I downloaded and used it from nuget.org.
I use the component for loading, modifying and save key values from yml configuration files.
Example:
When I load, modify and save the new yml file looks like this:
So it removed the
---
from start, added...
at the end and added a &number atauth:
key.This is my code for load and modify data:
So this new resulting yml file seems still be correct, but it confuses me, is everything correct in this case?
The text was updated successfully, but these errors were encountered: