System.Text.Json 命名空間

提供高效能、低配置和符合標準的功能來處理 JavaScript 物件標記法 (JSON),包括將物件序列化為 JSON 文字以及將 JSON 文字還原序列化為物件,且內建 UTF-8 支援。 Provides high-performance, low-allocating, and standards-compliant capabilities to process JavaScript Object Notation (JSON), which includes serializing objects to JSON text and deserializing JSON text to objects, with UTF-8 support built-in. 它也提供類型來讀取和寫入編碼為 UTF-8 的 JSON 文字,以及建立記憶體內部文件物件模型 (DOM),以便在資料的結構化檢視中隨機存取 JSON 元素。 It also provides types to read and write JSON text encoded as UTF-8, and to create an in-memory document object model (DOM) for random access of the JSON elements within a structured view of the data.



提供機制用於檢查 JSON 值的結構化內容,而不需自動具現化資料值。Provides a mechanism for examining the structural content of a JSON value without automatically instantiating data values.


定義當發現無效的 JSON 文字、超過定義的最大深度,或 JSON 文字與物件上的屬性類型不相容時,所擲回的自訂例外狀況物件。Defines a custom exception object that is thrown when invalid JSON text is encountered, when the defined maximum depth is passed, or the JSON text is not compatible with the type of a property on an object.


判斷用來將字串型名稱轉換為另一種格式的命名原則,例如 Camel 命名法大小寫格式。Determines the naming policy used to convert a string-based name to another format, such as a camel-casing format.


提供功能將物件或實值型別序列化為 JSON,並將 JSON 還原序列化為物件或實值型別。Provides functionality to serialize objects or value types to JSON and to deserialize JSON into objects or value types.


提供搭配 JsonSerializer 使用的選項。Provides options to be used with JsonSerializer.


提供高效能 API,以便對 UTF-8 編碼的 JSON 文字進行非快取的順向寫入。Provides a high-performance API for forward-only, non-cached writing of UTF-8 encoded JSON text.



提供使用者在剖析 JSON 以建立 JsonDocument 時,定義自訂行為的功能。Provides the ability for the user to define custom behavior when parsing JSON to create a JsonDocument.


表示 JsonDocument 內的特定 JSON 值。Represents a specific JSON value within a JsonDocument.


表示 JSON 陣列內容的列舉值。Represents an enumerator for the contents of a JSON array.


表示 JSON 物件屬性的列舉值。Represents an enumerator for the properties of a JSON object.


提供方法,將 UTF-8 或 UTF-16 編碼文字轉換成適用於 JSON 的格式。Provides methods to transform UTF-8 or UTF-16 encoded text into a form that is suitable for JSON.


表示 JSON 物件的單一屬性。Represents a single property for a JSON object.


可讓使用者定義讀取 JSON 時的自訂行為。Provides the ability for the user to define custom behavior when reading JSON.


定義不透明的類型,以保留和儲存必須提供給 Utf8JsonReader 的所有相關狀態資訊,以便在處理未完成資料之後繼續讀取。Defines an opaque type that holds and saves all the relevant state information, which must be provided to the Utf8JsonReader to continue reading after processing incomplete data.


可讓使用者在使用 Utf8JsonWriter 撰寫 JSON 時,定義自訂行為。Allows the user to define custom behavior when writing JSON using the Utf8JsonWriter.


提供高效能 API,以便對 UTF-8 編碼的 JSON 文字進行唯讀的順向存取。Provides a high-performance API for forward-only, read-only access to UTF-8 encoded JSON text.



定義 Utf8JsonReader 結構如何處理註解。Defines how the Utf8JsonReader struct handles comments.


指定以案例為基礎,可用來建構 JsonSerializerOptions 執行個體的預設序列化選項。Specifies scenario-based default serialization options that can be used to construct a JsonSerializerOptions instance.


定義組成 JSON 文字的各種 JSON 權杖。Defines the various JSON tokens that make up a JSON text.


指定 JSON 值的資料型別。Specifies the data type of a JSON value.


另請參閱 System.Text.Json.Serialization 命名空間,其中包含用於高階案例的屬性和 api,以及序列化和還原序列化專用的自訂。See also the System.Text.Json.Serialization namespace, which contains attributes and APIs for advanced scenarios and customization specific to serialization and deserialization.

如需詳細資訊,請參閱 System.Text.Js總覽For more information, see the System.Text.Json overview.