JsonExtensionDataAttribute 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
当属性的类型为 IDictionary<TKey,TValue> 时,没有匹配成员的任何属性都会在反序列化期间添加到该字典中,并在序列化期间中写入。
public ref class JsonExtensionDataAttribute sealed : System::Text::Json::Serialization::JsonAttribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)]
public sealed class JsonExtensionDataAttribute : System.Text.Json.Serialization.JsonAttribute
[System.AttributeUsage(System.AttributeTargets.Property, AllowMultiple=false)]
public sealed class JsonExtensionDataAttribute : System.Text.Json.Serialization.JsonAttribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)>]
type JsonExtensionDataAttribute = class
inherit JsonAttribute
[<System.AttributeUsage(System.AttributeTargets.Property, AllowMultiple=false)>]
type JsonExtensionDataAttribute = class
inherit JsonAttribute
Public NotInheritable Class JsonExtensionDataAttribute
Inherits JsonAttribute
- 继承
- 属性
注解
字典的值 TKey
必须是 String,并且 TValue
必须是 JsonElement 或 Object。
在反序列化期间,使用 Object时,“null”JSON 值被视为 null
对象引用,使用 JsonElement时,“null”被视为 JsonElement 并将其 ValueKind 设置为 JsonValueKind.Null。
在序列化期间,扩展数据属性的名称不包含在 JSON 中;扩展数据中包含的数据序列化为 JSON 对象的属性。
如果具有此扩展数据属性的类型上有多个属性,或者属性本身不是正确的 IDictionary<TKey,TValue> 类型, InvalidOperationException 则会在该类型的第一次序列化或反序列化期间引发 。
有关详细信息,请参阅 如何使用 System.Text.Json 处理溢出 JSON。
构造函数
JsonExtensionDataAttribute() |
初始化 JsonExtensionDataAttribute 类的新实例。 |
属性
TypeId |
在派生类中实现时,获取此 Attribute 的唯一标识符。 (继承自 Attribute) |
方法
Equals(Object) |
返回一个值,该值指示此实例是否与指定的对象相等。 (继承自 Attribute) |
GetHashCode() |
返回此实例的哈希代码。 (继承自 Attribute) |
GetType() |
获取当前实例的 Type。 (继承自 Object) |
IsDefaultAttribute() |
在派生类中重写时,指示此实例的值是否是派生类的默认值。 (继承自 Attribute) |
Match(Object) |
当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。 (继承自 Attribute) |
MemberwiseClone() |
创建当前 Object 的浅表副本。 (继承自 Object) |
ToString() |
返回表示当前对象的字符串。 (继承自 Object) |
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈