内容目录
引入这个库:
YamlDotNet
配置示例:
services.AddYamlDotNetSerializer(
serializer => serializer
.IncludeNonPublicProperties()
.WithTypeConverter(new OneOfConverter())
.WithEmissionPhaseObjectGraphVisitor(args => new ChainedObjectGraphVisitor(args.InnerVisitor)),
deserializer => deserializer
.WithNodeDeserializer(
inner => new Iso8601TimeSpanConverter(inner),
syntax => syntax.InsteadOf<ScalarNodeDeserializer>())
.WithNodeDeserializer(
inner => new OneOfDeserializer(inner),
syntax => syntax.InsteadOf<Iso8601TimeSpanConverter>()));
文章评论