JsonDocument.ParseValue(Utf8JsonReader) 方法


從提供的讀取器剖析一個 JSON 值 (包括物件或陣列)。Parses one JSON value (including objects or arrays) from the provided reader.

 static System::Text::Json::JsonDocument ^ ParseValue(System::Text::Json::Utf8JsonReader % reader);
public static System.Text.Json.JsonDocument ParseValue (ref System.Text.Json.Utf8JsonReader reader);
static member ParseValue : Utf8JsonReader -> System.Text.Json.JsonDocument
Public Shared Function ParseValue (ByRef reader As Utf8JsonReader) As JsonDocument



要讀取的讀取器。The reader to read.


JsonDocument,表示從讀取器讀取的值 (和巢狀值)。A JsonDocument representing the value (and nested values) read from the reader.


reader 包含不支援的選項。reader contains unsupported options.


目前的 reader 權杖不會啟動或表示值。The current reader token does not start or represent a value.

無法從讀取器讀取某個值。A value could not be read from the reader.


如果 readerTokenType 屬性 JsonTokenType.PropertyNameJsonTokenType.None,讀取器將會藉由一個呼叫 Utf8JsonReader.Read() 來前進,以判斷值的開頭。If the TokenType property of reader is JsonTokenType.PropertyName or JsonTokenType.None, the reader will advance by one call to Utf8JsonReader.Read() to determine the start of the value.

完成這個方法時,reader 位於 JSON 值中的最後一個 token。Upon completion of this method, reader is positioned at the final token in the JSON value. 如果擲回例外狀況,則讀取器會重設為呼叫方法時所處的狀態。If an exception is thrown, the reader is reset to the state it was in when the method was called.

這個方法會複製讀取器所處理的資料,因此不需要在傳回此方法的情況下維持資料完整性。This method makes a copy of the data the reader acted on, so there is no caller requirement to maintain data integrity beyond the return of this method.