Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
MissingMemberHandling 属性指示 Json.Net 在 json 文本包含 C# 类中缺少的属性时发出错误。我也想要相反的行为。如果 json 文本中缺少 C# 属性,我希望 Json.Net 发出错误。
我通过文档搜索完成了一点源代码挖掘
[JsonObject(ItemRequired = Required.Always)]
将上述内容应用于类标记反序列化所需的所有字段。同样,JsonObject属性是继承的,在我的情况下非常有帮助。
JsonObject