編集

次の方法で共有


JsonExtensionDataAttribute Class

Definition

When placed on a property of type IDictionary<TKey,TValue>, any properties that do not have a matching member are added to that dictionary during deserialization and written during serialization.

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
Inheritance
JsonExtensionDataAttribute
Attributes

Remarks

The dictionary's TKey value must be String, and TValue must be JsonElement or Object.

During deserialization, when using Object, a "null" JSON value is treated as a null object reference, and when using JsonElement, a "null" is treated as a JsonElement with ValueKind set to JsonValueKind.Null.

During serialization, the name of the extension data property is not included in the JSON; the data contained within the extension data is serialized as properties of the JSON object.

If there is more than one property on a type with this extension data attribute, or if the property itself is not of the correct IDictionary<TKey,TValue> type, an InvalidOperationException is thrown during the first serialization or deserialization of that type.

For more information, see How to handle overflow JSON with System.Text.Json.

Constructors

JsonExtensionDataAttribute()

Initializes a new instance of the JsonExtensionDataAttribute class.

Properties

TypeId

When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)

Methods

Equals(Object)

Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode()

Returns the hash code for this instance.

(Inherited from Attribute)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute()

When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object)

When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to