Skip to content
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

How do I get Serialize() to stop putting out anchor and reference labels? #15

Closed
fnjr opened this issue Dec 8, 2015 · 1 comment
Closed

Comments

@fnjr
Copy link

fnjr commented Dec 8, 2015

I basically want the output to be the same as the input and this code almost gets there except for the anchor and reference labels on the values of title and address.

string YamlData = YamlData =
    @"
    first: 'John'
    last: Smith
    title: 
    address: 
    list:
        - false
        - false
        - false";
var YamlSerializer = new SharpYaml.Serialization.Serializer();
Dictionary<object, object>  DocumentData = YamlSerializer.Deserialize<Dictionary<object, object>>(YamlData);
YamlSerializer.Settings.SortKeyForMapping = false;
YamlSerializer.Settings.EmitAlias = true;
YamlSerializer.Settings.EmitTags = true;

string YamlData2 = YamlSerializer.Serialize(DocumentData);
Debug.WriteLine(YamlData2);
@xoofx
Copy link
Owner

xoofx commented Dec 12, 2015

Settings have to be passed to the serializer constructor and cannot be changed after:

var settings = new SharpYaml.Serialization.SerializerSettings
{
    SortKeyForMapping = false,
    EmitAlias = false,
};
var serializer = new SharpYaml.Serialization.Serializer(settings);

var data = serializer.Deserialize<Dictionary<object, object>>(YamlData);

@xoofx xoofx closed this as completed Dec 12, 2015
@ghost ghost mentioned this issue Jan 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants