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

Emit empty string instead of null #47

Open
mdmoura opened this issue Mar 31, 2018 · 2 comments
Open

Emit empty string instead of null #47

mdmoura opened this issue Mar 31, 2018 · 2 comments

Comments

@mdmoura
Copy link

mdmoura commented Mar 31, 2018

I am serializing the following object:

public class Post {
  public Int32? Id { get; set; }
  public String Title { get; set; }
}

Post post = new Post { Id = null, Title = "Using SharpYaml" };

var result = serializer.Serialize(post);

On the output I get the following:

id: null
title: Using SharpYaml

Is it possible to display an empty string on Id when its value is null, e.g:

id: 
title: Using SharpYaml
@xoofx
Copy link
Owner

xoofx commented Mar 31, 2018

Afair, there are no options for doing this.

@mdmoura
Copy link
Author

mdmoura commented Mar 31, 2018

That would be useful as for example, in my case, the generated YAML files will be edited afterwards by content editors and having simply "id:" rather than "id:null" is easier to understand.

I was also testing YAMLDotNet and it is rendered as empty string ...

But I think YAMLDotNet has many limitations on configuration so I moved to SharpYaml

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

No branches or pull requests

2 participants