JsonIncludeAttribute 类

定义

指示应包含成员以用于序列化和反序列化。

public ref class JsonIncludeAttribute sealed : System::Text::Json::Serialization::JsonAttribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)]
public sealed class JsonIncludeAttribute : System.Text.Json.Serialization.JsonAttribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)>]
type JsonIncludeAttribute = class
    inherit JsonAttribute
Public NotInheritable Class JsonIncludeAttribute
Inherits JsonAttribute
继承
JsonIncludeAttribute
属性

注解

应用于属性时,此属性指示非公共 gettersetter 可用于序列化和反序列化。

注意

即使使用此属性,序列化源生成器仍仅限于生成的代码 可访问 的非公共成员。 可访问 的非公共成员包括以下成员:

  • internal 如果与生成的上下文位于同一程序集中,则为 。
  • protectedprotected internal生成的上下文位于派生自 该类型的类中时, 或 private protected
  • private 如果类型与生成的上下文嵌套在相同的类中,则为 。

在 .NET 6 和 .NET 7 中,不支持非公共属性。

构造函数

JsonIncludeAttribute()

初始化 JsonIncludeAttribute 的新实例。

属性

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。

(继承自 Attribute)

方法

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。

(继承自 Attribute)
GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。

(继承自 Attribute)
Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于