Does YamlDotNet support deserializing a document where there are fields in the document that do not map to a field in the resulting object? For example:
Given a type:
public class Foo {
public string AField { get; set; }
}
If I use YamlDotNet's Deserialize on the following document it generates an exception:
Foo:
AField: This is a test
NotFoundField: This field is not supported yet
Looking at the YAML spec it should be allowable that the non-matching field should be ignored. Looking at the YamlDotNet code, it looks like it is assumed that the all fields in the document will map into the resulting object.
Is there an existing way to make the parsing "permissive" or am I going to need to modify YamDotNet to allow this?
The current behavior of the deserializer is to assume that each key maps to a property.
It should not be difficult to implement the behavior that you need, though.
There is now a flag to configure this behavior: https://github.com/aaubry/YamlDotNet/pull/88
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.