0
我使用YamlDotNet序列化对象和引用和值类型。我期望完成的是我的整数值零保留在输出的yaml中,但空值将被丢弃。 EmitDefaults看起来为数值放弃'0'。我明白null是引用类型的默认值。 Json.Net解决了这个破与它分为以下几个特性:YamlDotNet SerializationOptions.EmitDefaults行为
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore,
有什么办法来完成以下?
class foo
{
int index {get;set;}
string bar {get;set;}
}
new foo { index =0; bar = null }
would yield the following yaml:
index: 0
new foo { index =0; bar = "bar" }
would yield the following yaml:
index: 0
bar: bar
感谢