xoofx / SharpYaml

SharpYaml is a .NET library for YAML compatible with CoreCLR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ignore unmapped properties in YAML

Cinchoo opened this issue · comments

Given a YAML file that contains more information than the object deserializing it, the current implementation will throw an exception because there is not a corresponding object property for all properties in the YAML file.

new SharpYaml.Serialization.SerializerSettings()
{
    IgnoreUnmatchedProperties = true
}

doesn't this help?

new SharpYaml.Serialization.SerializerSettings()
{
    IgnoreUnmatchedProperties = true
}

doesn't this help?

I am seeing the same issue. Setting the property IgnoreUnmatchedProperties to true only works if the the property's value is a primitive type. For any property that is set to a map or list will throw an exception.

Seeing the same. Getting Expected 'Scalar', got 'MappingStart' error when setting IgnoreUnmatchedProperties to true and the yaml having an unmatched property that's a map.

Same problem...

@xoofx can you guide me a little? I can try to create a PR.

I understand that the problem has to be around here:

if (!TryReadMember(ref objectContext, out var memberScalar, out var memberName))

var memberResult = TryReadMemberCore(ref objectContext, out memberScalar, out memberName);