xoofx / SharpYaml

SharpYaml is a .NET library for YAML compatible with CoreCLR
Other
336 stars 61 forks source link

The string "null" should be deserialized as a string, not as null #106

Closed mstefarov closed 2 years ago

mstefarov commented 2 years ago

I have a piece of YAML that contains the string literal "null". Other YAML parsers (e.g. YamlDotNet) treat this as a string "null", but SharpYaml interprets it as just null.

Example:

values:
  - name: "null"
    value: 5
    summary: No fill.
public class YEnum
{
    public List<YEnumValue> Values { get; set; } = new();
}
public class YEnumValue
{
    public string Name { get; set; }
    public int Value { get; set; }
    public string Summary { get; set; }
}

Expected deserialization result: myEnum.Values[0].Name == "null" Actual deserialization result: myEnum.Values[0].Name == null